n8n_stack/scripts/yunohost-hook-restore-n8n-proxy.sh

34 lines
1.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# YunoHost post_app_upgrade hook
# Deploy to: /etc/yunohost/hooks.d/post_app_upgrade/99-n8n-proxy
# Permissions: chmod 700
#
# Restores the n8n reverse-proxy location block in my_webapp.conf
# after a "yunohost app upgrade my_webapp" overwrites it.
set -euo pipefail
CONF=/etc/nginx/conf.d/n8n.linix.de.d/my_webapp.conf
[[ -f "$CONF" ]] || exit 0
grep -q 'proxy_pass' "$CONF" && exit 0
cat > "$CONF" << 'NGINX'
#sub_path_only rewrite ^/$ / permanent;
location / {
proxy_pass http://192.168.179.124:8088;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
client_max_body_size 50m;
}
NGINX
nginx -t && systemctl reload nginx
echo "[n8n-proxy hook] nginx proxy config restored after my_webapp upgrade."