From 813957624fbe0e2413866d29ecc21e20ac4c0f3d Mon Sep 17 00:00:00 2001 From: Gofannon Date: Mon, 9 Jul 2018 22:15:49 +0200 Subject: [PATCH] [fix] Fix issue alias_traversal See https://github.com/YunoHost/example_ynh/commit/d3f411736981ea2b748b9a1459429b4653556bc7 --- 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 ee61519..0f68b0c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,5 @@ -location __PATH__ { +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { # Path to source alias __FINALPATH__/ ; diff --git a/scripts/install b/scripts/install index 6f496c4..f549c7d 100755 --- a/scripts/install +++ b/scripts/install @@ -79,6 +79,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 827c77f..f742118 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -181,6 +181,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