diff --git a/conf/nginx.conf b/conf/nginx.conf index fef8e48..b68bbbd 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,5 @@ -location @YNH_APPNAME__proxy { - proxy_pass YNH_PROXY_PATH; +location @__NAME____proxy { + proxy_pass __PROXY_PATH__; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -18,11 +18,11 @@ location @YNH_APPNAME__proxy { } # Support relative URLs -location = YNH_LOCATION { - return 302 YNH_LOCATION/; +location = __PATH_URL__ { + return 302 __PATH_URL__/; } -location YNH_LOCATION/ { - alias YNH_ASSETS_PATH; - try_files $uri @YNH_APPNAME__proxy; +location __PATH_URL__/ { + alias __ASSETS_PATH__; + try_files $uri @__NAME____proxy; } diff --git a/scripts/_common.sh b/scripts/_common.sh index 73492e7..373b908 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -24,30 +24,3 @@ rp_validate_proxy_path() { fi fi } - -# Make reverse proxy public if $1 is 1 -# Yunohost boolean params are 1 if true -rp_make_permissions() { - ynh_script_progression --message="Configuring permissions..." --weight=2 - - if [ $1 = 1 ]; then - ynh_permission_update --permission="main" --add="visitors" - fi -} - -# (re)generate nginx config -rp_make_webconfig() { - ynh_script_progression --message="Configuring NGINX web server..." --weight=1 - - # Nginx configuration - ynh_replace_string "YNH_LOCATION" "$path_url" ../conf/nginx.conf - ynh_replace_string "YNH_PROXY_PATH" "$proxy_path" ../conf/nginx.conf - ynh_replace_string "YNH_APPNAME" "$app" ../conf/nginx.conf - ynh_replace_string "YNH_ASSETS_PATH" "$assets_path" ../conf/nginx.conf - cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf -} - -rp_reload_web() { - ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - ynh_systemd_action --service_name=nginx --action=reload -} diff --git a/scripts/change_url b/scripts/change_url index 38cff43..12acc82 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -33,15 +33,17 @@ new_path=$YNH_APP_NEW_PATH #================================================= # Nginx configuration -ynh_replace_string "$old_path {" "$new_path {" /etc/nginx/conf.d/$old_domain.d/$app.conf -ynh_replace_string "${old_path}/ {" "${new_path}/ {" /etc/nginx/conf.d/$old_domain.d/$app.conf -ynh_replace_string "302 ${old_path}/" "302 ${new_path}/" /etc/nginx/conf.d/$old_domain.d/$app.conf +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +path_url="$new_path" +domain="$old_domain" +proxy_path="$(ynh_app_setting_get --app=$app --key=proxy_path)" +assets_path="$(ynh_app_setting_get --app=$app --key=assets_path)" +ynh_add_nginx_config -# Maybe only path part has changed... only move file if domain has changed +# Move file to new domain if domain has changed [[ "$old_domain" != "$new_domain" ]] && mv /etc/nginx/conf.d/$old_domain.d/$app.conf /etc/nginx/conf.d/$new_domain.d/$app.conf -# Reload nginx -rp_reload_web #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 50d716f..6071afd 100644 --- a/scripts/install +++ b/scripts/install @@ -44,13 +44,15 @@ ynh_app_setting_set --app=$app --key=proxy_path --value=$proxy_path ynh_app_setting_set --app=$app --key=assets_path --value=$assets_path # Configure nginx -rp_make_webconfig +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +ynh_add_nginx_config -# Make app public if necessary -rp_make_permissions $is_public - -# Reload nginx -rp_reload_web +# Make app public if necessary (yunohost setting boolean is 1 when true) +ynh_script_progression --message="Configuring permissions..." --weight=2 +if [ $is_public -eq 1 ]; then + ynh_permission_update --permission="main" --add="visitors" +fi #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 16efd3b..6a2cff8 100644 --- a/scripts/remove +++ b/scripts/remove @@ -26,7 +26,8 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) ynh_secure_remove /etc/nginx/conf.d/$domain.d/$app.conf # Reload nginx -rp_reload_web +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index ff00b3f..a8bb89f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -42,7 +42,8 @@ NGINX_CONF="/etc/nginx/conf.d/${domain}.d/${app}.conf" ynh_restore_file "$NGINX_CONF" # Reload nginx -rp_reload_web +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 811d69e..bd2d585 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -42,10 +42,9 @@ ynh_abort_if_errors rp_validate_proxy_path "$proxy_path" # Configure nginx -rp_make_webconfig - -# Reload nginx -rp_reload_web +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +ynh_add_nginx_config #================================================= # END OF SCRIPT