From 04c67cd403dd6891fd605a39584ccccc000e753b Mon Sep 17 00:00:00 2001 From: Binnette Date: Wed, 6 Apr 2022 22:55:26 +0200 Subject: [PATCH 1/7] move selfoss to sublocation /selfoss --- conf/nginx.conf | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index f98a6c8..48a0497 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,28 +1,34 @@ -location / { +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location /selfoss { # Path to source - alias __FINALPATH__/; - - index index.php; - - try_files $uri /public/$uri /index.php; + root __FINALPATH__/; + access_log /var/log/nginx/rss.access.log; + error_log /var/log/nginx/rss.error.log; + + #index index.php; + #try_files $uri /public/$uri /index.php; location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; - fastcgi_index index.php; + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + include fastcgi_params; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $request_filename; } - location ~ ^/(favicons|thumbnails)/.*$ { - try_files $uri /data/$uri; - } + location ~ ^/selfoss/((favicons|thumbnails)/.+)$ { + try_files /selfoss/data/$1 =404; + } - location ~* ^/(data\/logs|data\/sqlite|config\.ini|\.ht) { - deny all; - } + location ~ ^/selfoss/$ { + index index.php; + } + + location ~ ^/selfoss/(.+)$ { + try_files /selfoss/public/$1 /selfoss/index.php$is_args$args; + } } From 619c43a0e55902af3af8addfabdf86a5a444596a Mon Sep 17 00:00:00 2001 From: Binnette Date: Wed, 6 Apr 2022 23:01:02 +0200 Subject: [PATCH 2/7] Add path param --- manifest.json | 6 ++++++ scripts/install | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 0cabc5e..6eccdff 100644 --- a/manifest.json +++ b/manifest.json @@ -34,6 +34,12 @@ "name": "domain", "type": "domain" }, + { + "name": "path", + "type": "path", + "example": "/selfoss", + "default": "/selfoss" + }, { "name": "is_public", "type": "boolean", diff --git a/scripts/install b/scripts/install index 50511ab..d804d35 100755 --- a/scripts/install +++ b/scripts/install @@ -21,7 +21,7 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN -path_url="/" +path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC app=$YNH_APP_INSTANCE_NAME From 4a82ce6369d25679c51dc7eb9f207f9069339cab Mon Sep 17 00:00:00 2001 From: Binnette Date: Wed, 6 Apr 2022 23:26:50 +0200 Subject: [PATCH 3/7] Fix Nginx conf --- conf/nginx.conf | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 48a0497..46e5e46 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,14 +1,9 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; -location /selfoss { +location /__PATH__ { # Path to source - root __FINALPATH__/; - access_log /var/log/nginx/rss.access.log; - error_log /var/log/nginx/rss.error.log; - - #index index.php; - #try_files $uri /public/$uri /index.php; - + alias __FINALPATH__/; + location ~ [^/]\.php(/|$) { fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_index index.php; @@ -20,15 +15,15 @@ location /selfoss { fastcgi_param SCRIPT_FILENAME $request_filename; } - location ~ ^/selfoss/((favicons|thumbnails)/.+)$ { - try_files /selfoss/data/$1 =404; + location ~ ^/__PATH__/((favicons|thumbnails)/.+)$ { + try_files /__PATH__/data/$1 =404; } - location ~ ^/selfoss/$ { + location ~ ^/__PATH__/$ { index index.php; } - location ~ ^/selfoss/(.+)$ { - try_files /selfoss/public/$1 /selfoss/index.php$is_args$args; + location ~ ^/__PATH__/(.+)$ { + try_files /__PATH__/public/$1 /__PATH__/index.php$is_args$args; } } From 679a0a201dfafc93252423f6de7c2492a335e640 Mon Sep 17 00:00:00 2001 From: Binnette Date: Wed, 6 Apr 2022 23:45:40 +0200 Subject: [PATCH 4/7] Fix nginx.conf --- conf/nginx.conf | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 46e5e46..4fcabbb 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,9 +1,8 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; -location /__PATH__ { +location __PATH__ { + + root /var/www/; - # Path to source - alias __FINALPATH__/; - location ~ [^/]\.php(/|$) { fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; fastcgi_index index.php; @@ -15,15 +14,15 @@ location /__PATH__ { fastcgi_param SCRIPT_FILENAME $request_filename; } - location ~ ^/__PATH__/((favicons|thumbnails)/.+)$ { - try_files /__PATH__/data/$1 =404; + location ~ ^__PATH__/((favicons|thumbnails)/.+)$ { + try_files __PATH__/data/$1 =404; } - location ~ ^/__PATH__/$ { + location ~ ^__PATH__/$ { index index.php; } - location ~ ^/__PATH__/(.+)$ { - try_files /__PATH__/public/$1 /__PATH__/index.php$is_args$args; + location ~ ^__PATH__/(.+)$ { + try_files __PATH__/public/$1 __PATH__/index.php$is_args$args; } } From 27802b07243dfa5873d012b85d8628c1e39761fb Mon Sep 17 00:00:00 2001 From: Binnette Date: Thu, 22 Dec 2022 10:21:00 +0100 Subject: [PATCH 5/7] Use alias instead of root --- conf/nginx.conf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 4fcabbb..edfd863 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,10 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; location __PATH__ { - root /var/www/; + # Path to source + alias __FINALPATH__/; + + # ~ instruct nginx to perform a case-sensitive regular expression match location ~ [^/]\.php(/|$) { fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; From bb35617d3e831e06e36a326381a4fee1c85a9931 Mon Sep 17 00:00:00 2001 From: Binnette Date: Fri, 23 Dec 2022 10:40:59 +0100 Subject: [PATCH 6/7] Nginx: use alias instead of root --- conf/nginx.conf | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index edfd863..c3ced7e 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,31 +1,36 @@ #sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; -location __PATH__ { +location __PATH__/ { # Path to source alias __FINALPATH__/; - # ~ instruct nginx to perform a case-sensitive regular expression match - - location ~ [^/]\.php(/|$) { - fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; - fastcgi_index index.php; - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - - include fastcgi_params; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $request_filename; - } + # index.php is a router, it contains a lot of routes: + # / is serving the home page, /update is refreshing all feeds, etc. + # So we need to rewrite all URLs to give them to the router inside index.php + rewrite ^__PATH__/.*$ __PATH__/index.php?$args; + # feeds favicons and thumbnails are stored in subfolder data location ~ ^__PATH__/((favicons|thumbnails)/.+)$ { try_files __PATH__/data/$1 =404; } - location ~ ^__PATH__/$ { - index index.php; + # statics assets are stored in public folder + location ~ ^__PATH__/(.*\.(js|ico|gif|jpg|png|css|map|asc|txt|svg|xml|webmanifest)).*$ { + try_files __PATH__/public/$1 =404; } - location ~ ^__PATH__/(.+)$ { - try_files __PATH__/public/$1 __PATH__/index.php$is_args$args; + # Regex to match PHP files + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; } + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; } From c954056f310e2b9ecada4e3c4c610c2863e7cedc Mon Sep 17 00:00:00 2001 From: ericgaspar Date: Fri, 23 Dec 2022 11:24:59 +0100 Subject: [PATCH 7/7] Update check_process --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 86d519e..a94739b 100644 --- a/check_process +++ b/check_process @@ -5,7 +5,7 @@ is_public=1 ; Checks pkg_linter=1 - setup_sub_dir=0 + setup_sub_dir=1 setup_root=1 setup_nourl=0 setup_private=1