From a5a5ea5e646318c190da68935a4d973d1840d262 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Tue, 24 Nov 2020 23:40:11 +0100 Subject: [PATCH] Fix NGINX --- conf/nginx.conf | 18 +++++++++--------- scripts/install | 7 +++++++ scripts/upgrade | 7 +++++++ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index f8ed873..63531b1 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -9,18 +9,18 @@ location __PATH__/ { rewrite ^ https://$server_name$request_uri? permanent; } - index index.html index.php; + index index.php; - try_files $uri $uri/ /index.php?q=$uri&$args; + try_files $uri $uri/ __PATH_HACK__/index.php$is_args$args; location ~ [^/]\.php(/|$) { - fastcgi_split_path_info ^(.+?\.php)(/.*)$; - fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; - - fastcgi_index index.php; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param PATH_INFO $fastcgi_path_info; - include fastcgi_params; + 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. diff --git a/scripts/install b/scripts/install index df562b6..f519fec 100644 --- a/scripts/install +++ b/scripts/install @@ -70,6 +70,13 @@ ynh_setup_source --dest_dir="$final_path" #================================================= ynh_script_progression --message="Configuring NGINX web server..." +# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 ) +if [ $path_url = "/" ]; then + ynh_replace_string "__PATH_HACK__" "" "../conf/nginx.conf" +else + ynh_replace_string "__PATH_HACK__" "$path_url/$path_url" "../conf/nginx.conf" +fi + # Create a dedicated NGINX config ynh_add_nginx_config diff --git a/scripts/upgrade b/scripts/upgrade index 25bb381..b36efd3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -102,6 +102,13 @@ ynh_secure_remove "$tmpdir" #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." +# Bug in Nginx with locations and aliases (see http://stackoverflow.com/a/35102259 ) +if [ $path_url = "/" ]; then + ynh_replace_string "__PATH_HACK__" "" "../conf/nginx.conf" +else + ynh_replace_string "__PATH_HACK__" "$path_url/$path_url" "../conf/nginx.conf" +fi + # Create a dedicated NGINX config ynh_add_nginx_config