diff --git a/conf/nginx.conf b/conf/nginx.conf index 7cad30e..0300bad 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -165,15 +165,6 @@ location ^~ __PATH__/ { try_files $uri / __PATH__/index.php$request_uri; } - __STRING_USE_NOTIFY_PUSH__location ^~ __PATH__/push/ { - __STRING_USE_NOTIFY_PUSH__ proxy_pass http://unix:__FINAL_PATH__/notify-push.sock:/; - __STRING_USE_NOTIFY_PUSH__ proxy_http_version 1.1; - __STRING_USE_NOTIFY_PUSH__ proxy_set_header Upgrade $http_upgrade; - __STRING_USE_NOTIFY_PUSH__ proxy_set_header Connection "Upgrade"; - __STRING_USE_NOTIFY_PUSH__ proxy_set_header Host $host; - __STRING_USE_NOTIFY_PUSH__ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - __STRING_USE_NOTIFY_PUSH__} - # show YunoHost panel access include conf.d/yunohost_panel.conf.inc; } diff --git a/manifest.toml b/manifest.toml index 8e48397..8d47489 100644 --- a/manifest.toml +++ b/manifest.toml @@ -62,7 +62,7 @@ ram.runtime = "512M" default = "yes" [install.enable_notify_push] - ask.en = "Configure the High Performance Backend?", + ask.en = "Configure the High Performance Backend?" ask.fr = "Configurer le Backend Hautes Performances ?" type = "boolean" default = false diff --git a/scripts/_common.sh b/scripts/_common.sh index 65cce78..ea1fa91 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -40,6 +40,45 @@ is_url_handled() { fi } +# Adapted from nginx helpers +ynh_add_nginx_notify_push_config() { + + local finalnginxconf="/etc/nginx/conf.d/$domain.d/${app}_notify_push.conf" + + ynh_add_config --template="nginx_notify_push.conf" --destination="$finalnginxconf" + + if [ "${path_url:-}" != "/" ]; then + ynh_replace_string --match_string="^#sub_path_only" --replace_string="" --target_file="$finalnginxconf" + else + ynh_replace_string --match_string="^#root_path_only" --replace_string="" --target_file="$finalnginxconf" + fi + + ynh_store_file_checksum --file="$finalnginxconf" + + ynh_systemd_action --service_name=nginx --action=reload +} + +ynh_remove_nginx_notify_push_config() { + ynh_secure_remove --file="/etc/nginx/conf.d/$domain.d/${app}_notify_push.conf" + ynh_systemd_action --service_name=nginx --action=reload +} + + +ynh_change_url_nginx_notify_push_config() { + + # Make a backup of the original NGINX config file if manually modified + # (nb: this is possibly different from the same instruction called by + # ynh_add_config inside ynh_add_nginx_notify_push_config because the path may have + # changed if we're changing the domain too...) + local old_nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/${app}_notify_push.conf + ynh_backup_if_checksum_is_different --file="$old_nginx_conf_path" + ynh_delete_file_checksum --file="$old_nginx_conf_path" + ynh_secure_remove --file="$old_nginx_conf_path" + + # Regen the nginx conf + ynh_add_nginx_notify_push_config +} + #================================================= # FUTURE OFFICIAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index c94d43b..96685d0 100755 --- a/scripts/backup +++ b/scripts/backup @@ -32,6 +32,7 @@ ynh_backup --src_path="$data_dir" --is_big #================================================= ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/${app}_notify_push.conf" #================================================= # BACKUP THE PHP-FPM CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index afd2218..e9b7cf3 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -16,7 +16,7 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- ynh_change_url_nginx_config -ynh_change_url_nginx_config +ynh_change_url_nginx_notify_push_config #================================================= # SPECIFIC MODIFICATIONS diff --git a/scripts/install b/scripts/install index e575b1c..b2d72d7 100755 --- a/scripts/install +++ b/scripts/install @@ -51,7 +51,7 @@ fi if [ $enable_notify_push -eq 1 ] then - ynh_add_nginx_config "${app}-notify-push" + ynh_add_nginx_notify_push_config fi # Create a dedicated NGINX config @@ -284,17 +284,6 @@ ynh_script_progression --message="Configuring Fail2Ban..." --weight=8 # Create a dedicated Fail2Ban config ynh_add_fail2ban_config --logpath="/var/log/$app/nextcloud.log" --failregex="^.*Login failed: '.*' \(Remote IP: ''.*$" --max_retry=5 -#================================================= -# CONFIGURE NOTIFY_PUSH APP -#================================================= - -if [ $use_notify_push -eq 1 ] -then - ynh_permission_create --permission="hpb" --label="High Performance Backend" --url="/push" --additional_urls="/index.php/apps/notify_push/" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" -fi - -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # CHECK IF NOTIFY_PUSH WORKS #================================================= diff --git a/scripts/remove b/scripts/remove index 4331c2c..b7fb0bc 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,6 +12,7 @@ ynh_script_progression --message="Removing system configurations related to $app # Remove the dedicated NGINX config ynh_remove_nginx_config +ynh_remove_nginx_notify_push_config # Remove the dedicated PHP-FPM config ynh_remove_fpm_config diff --git a/scripts/restore b/scripts/restore index ff4252e..87f77ea 100755 --- a/scripts/restore +++ b/scripts/restore @@ -36,6 +36,7 @@ ynh_add_fpm_config #================================================= ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/${app}_notify_push.conf" # Check if .well-known is available for this domain if is_url_handled --domain="$domain" --path="/.well-known/caldav" || is_url_handled --domain="$domain" --path="/.well-known/carddav" diff --git a/scripts/upgrade b/scripts/upgrade index 1bda9f1..fbc32d1 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -363,7 +363,7 @@ ynh_add_nginx_config if [ $enable_notify_push -eq 1 ] then - ynh_add_nginx_config "${app}-notify-push" + ynh_add_nginx_notify_push_config fi #=================================================