From 3e4bbc7de65177eccd75827943731d45b52887b6 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Wed, 22 Feb 2017 17:05:27 +0000 Subject: [PATCH 1/6] Update nginx.conf to have only one file --- conf/nginx.conf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index e934ffe..612163b 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,13 +1,13 @@ location ^~ YNH_WWW_PATH { - root /var/www; - try_files $uri $uri/ /YNH_WWW_APP/index.php?$query_string; - index /YNH_WWW_APP/index.php; + alias YNH_WWW_FINALPATH/ ; + try_files $uri $uri/ /YNH_WWW_ROOTAPP/index.php?$query_string; + index /YNH_WWW_ROOTAPP/index.php; - location YNH_WWW_PATH/ { try_files $uri $uri/ /YNH_WWW_APP/index.php?$query_string; } - location YNH_WWW_PATH/api { try_files $uri $uri/ /YNH_WWW_APP/api.php?$query_string; } - location YNH_WWW_PATH/admin { try_files $uri $uri/ /YNH_WWW_APP/admin.php?$query_string; } + location YNH_WWW_ROOTPATH/ { try_files $uri $uri/ /YNH_WWW_ROOTAPP/index.php?$query_string; } + location YNH_WWW_ROOTPATH/api { try_files $uri $uri/ /YNH_WWW_ROOTAPP/api.php?$query_string; } + location YNH_WWW_ROOTPATH/admin { try_files $uri $uri/ /YNH_WWW_ROOTAPP/admin.php?$query_string; } - location YNH_WWW_PATH/flarum { + location YNH_WWW_ROOTPATH/flarum { deny all; return 404; } From b1ae7f973e17116d3f1261824b08f3d6d50bf565 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Wed, 22 Feb 2017 17:07:41 +0000 Subject: [PATCH 2/6] Delete nginx_root.conf --- conf/nginx_root.conf | 60 -------------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 conf/nginx_root.conf diff --git a/conf/nginx_root.conf b/conf/nginx_root.conf deleted file mode 100644 index 23411f6..0000000 --- a/conf/nginx_root.conf +++ /dev/null @@ -1,60 +0,0 @@ -root /var/www/YNH_WWW_APP; -location ^~ / { - try_files $uri $uri/ /index.php?$query_string; - index /index.php; - - location / { try_files $uri $uri/ /index.php?$query_string; } - location /api { try_files $uri $uri/ /api.php?$query_string; } - location /admin { try_files $uri $uri/ /admin.php?$query_string; } - - location /flarum { - deny all; - return 404; - } - - location ~* \.php$ { - fastcgi_split_path_info ^(.+.php)(/.+)$; - fastcgi_pass unix:/var/run/php5-fpm-YNH_WWW_APP.sock; - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param HTTP_PROXY ""; # Fix for https://httpoxy.org/ vulnerability - fastcgi_index index.php; - fastcgi_read_timeout 600; - } - - location ~* \.html$ { - expires -1; - } - - location ~* \.(css|js|gif|jpe?g|png)$ { - expires 1M; - add_header Pragma public; - add_header Cache-Control "public, must-revalidate, proxy-revalidate"; - } - - gzip on; - gzip_http_version 1.1; - gzip_vary on; - gzip_comp_level 6; - gzip_proxied any; - gzip_types application/atom+xml - application/javascript - application/json - application/vnd.ms-fontobject - application/x-font-ttf - application/x-web-app-manifest+json - application/xhtml+xml - application/xml - font/opentype - image/svg+xml - image/x-icon - text/css - text/plain - text/xml; - gzip_buffers 16 8k; - gzip_disable "MSIE [1-6]\.(?!.*SV1)"; - - - # Include SSOWAT user panel. - # include conf.d/yunohost_panel.conf.inc; -} From 0c751243d93456323278ddbd712bd95d9e57cba4 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Wed, 22 Feb 2017 17:08:55 +0000 Subject: [PATCH 3/6] Update to nginx section --- scripts/install | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 837b0fd..eed6289 100644 --- a/scripts/install +++ b/scripts/install @@ -89,14 +89,16 @@ ynh_app_setting_set "$app" mysqlpwd "$dbpass" ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" ### Nginx ### -if [ $path = "" ]; then -nginx_conf=../conf/nginx_root.conf +nginxconf="../conf/nginx.conf" +if [ $path = "/" ]; then + sed -i "s@YNH_WWW_ROOTPATH@@g" ../conf/nginx.conf + sed -i "s@/YNH_WWW_ROOTAPP@@g" ../conf/nginx.conf else -nginx_conf=../conf/nginx.conf + sed -i "s@YNH_WWW_ROOTPATH@$path@g" ../conf/nginx.conf + sed -i "s@YNH_WWW_ROOTAPP@$app@g" ../conf/nginx.conf fi sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf -sed -i "s@YNH_WWW_ALIAS@$app/@g" $nginx_conf -sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf +sed -i "s@YNH_WWW_FINALPATH@$final_path@g" $nginx_conf sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf ### PHP ### From 07a8120a386b88911dfe909f154ae3118c68cf7d Mon Sep 17 00:00:00 2001 From: Titus PiJean Date: Wed, 22 Feb 2017 18:33:07 +0100 Subject: [PATCH 4/6] Fix $nginx_conf -> $nginxconf --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index eed6289..bcecbce 100644 --- a/scripts/install +++ b/scripts/install @@ -97,9 +97,9 @@ else sed -i "s@YNH_WWW_ROOTPATH@$path@g" ../conf/nginx.conf sed -i "s@YNH_WWW_ROOTAPP@$app@g" ../conf/nginx.conf fi -sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf -sed -i "s@YNH_WWW_FINALPATH@$final_path@g" $nginx_conf -sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf +sed -i "s@YNH_WWW_PATH@$path@g" $nginxconf +sed -i "s@YNH_WWW_FINALPATH@$final_path@g" $nginxconf +sudo cp $nginxconf /etc/nginx/conf.d/$domain.d/$app.conf ### PHP ### sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf From dd43f8e27a13d7c5062192abb64f187e36f14787 Mon Sep 17 00:00:00 2001 From: Titus PiJean Date: Wed, 22 Feb 2017 18:40:55 +0100 Subject: [PATCH 5/6] Fix socket dummy variable name --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 612163b..7114064 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -14,7 +14,7 @@ location ^~ YNH_WWW_PATH { location ~* \.php$ { fastcgi_split_path_info ^(.+.php)(/.+)$; - fastcgi_pass unix:/var/run/php5-fpm-YNH_WWW_APP.sock; + fastcgi_pass unix:/var/run/php5-fpm-YNH_WWW_ROOTAPP.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param HTTP_PROXY ""; # Fix for https://httpoxy.org/ vulnerability From 3492031818963fc3439cc1a8a65ab3898b6180cf Mon Sep 17 00:00:00 2001 From: Titus PiJean Date: Wed, 22 Feb 2017 18:53:47 +0100 Subject: [PATCH 6/6] Fix PHP SCRIPT_FILENAME --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 7114064..87ee77e 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -16,7 +16,7 @@ location ^~ YNH_WWW_PATH { fastcgi_split_path_info ^(.+.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm-YNH_WWW_ROOTAPP.sock; include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_param HTTP_PROXY ""; # Fix for https://httpoxy.org/ vulnerability fastcgi_index index.php; fastcgi_read_timeout 600;