From 7693c0526af3e2df285e5a46af30877fb7e5ba4b Mon Sep 17 00:00:00 2001 From: Jimmy Monin Date: Sun, 27 May 2018 21:19:10 +0200 Subject: [PATCH] Fix alias traversal bug --- conf/nginx.conf | 3 ++- scripts/install | 5 +++++ scripts/upgrade | 5 +++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 58d32a3..891813e 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,5 @@ -location __PATH__ { +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { alias __FINALPATH__/ ; if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; diff --git a/scripts/install b/scripts/install index 3fc564f..97acafc 100644 --- a/scripts/install +++ b/scripts/install @@ -77,6 +77,11 @@ ynh_setup_source "$final_path" # Create a dedicated nginx config ynh_add_nginx_config +if [ "$path_url" != "/" ] +then + ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf" +fi +ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # CREATE DEDICATED USER diff --git a/scripts/upgrade b/scripts/upgrade index c8e8b97..45ff9df 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -69,6 +69,11 @@ ynh_setup_source "$final_path" # Create a dedicated nginx config ynh_add_nginx_config +if [ "$path_url" != "/" ] +then + ynh_replace_string "^#sub_path_only" "" "/etc/nginx/conf.d/$domain.d/$app.conf" +fi +ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # CREATE DEDICATED USER