Fix Onion-Location on SPA responses behind nginx add_header.

Render the header inside location / so it is not dropped by other location headers; remove the ineffective server-level directive.
This commit is contained in:
2026-10-28 23:12:08 +01:00
parent b97fcc2b20
commit adb1d7bca9
3 changed files with 6 additions and 11 deletions
-2
View File
@@ -22,7 +22,5 @@ server {
ssl_certificate /etc/nginx/certs/live/${CLEARNET_DOMAIN}/fullchain.pem; ssl_certificate /etc/nginx/certs/live/${CLEARNET_DOMAIN}/fullchain.pem;
ssl_certificate_key /etc/nginx/certs/live/${CLEARNET_DOMAIN}/privkey.pem; ssl_certificate_key /etc/nginx/certs/live/${CLEARNET_DOMAIN}/privkey.pem;
${ONION_LOCATION_HEADER}
include /etc/nginx/snippets/private-image-locations.conf; include /etc/nginx/snippets/private-image-locations.conf;
} }
+5 -9
View File
@@ -9,7 +9,9 @@ UPLOAD_MAX_REQUEST_BODY_BYTES=$(( (max_image_bytes * 4 + 2) / 3 + json_padding )
export UPLOAD_MAX_REQUEST_BODY_BYTES BACKEND_PORT export UPLOAD_MAX_REQUEST_BODY_BYTES BACKEND_PORT
render_locations() { render_locations() {
envsubst '${BACKEND_PORT} ${UPLOAD_MAX_REQUEST_BODY_BYTES}' \ export ONION_LOCATION_HEADER="add_header Onion-Location \"http://${ONION_HOSTNAME}\$request_uri\" always;"
envsubst '${BACKEND_PORT} ${UPLOAD_MAX_REQUEST_BODY_BYTES} ${ONION_LOCATION_HEADER}' \
< /etc/nginx/templates/snippets/private-image-locations.conf.template \ < /etc/nginx/templates/snippets/private-image-locations.conf.template \
> /etc/nginx/snippets/private-image-locations.conf > /etc/nginx/snippets/private-image-locations.conf
} }
@@ -20,15 +22,9 @@ render_server() {
surface="$3" surface="$3"
if [ "$surface" = "clearnet" ]; then if [ "$surface" = "clearnet" ]; then
if [ -n "${ONION_HOSTNAME:-}" ]; then
export ONION_LOCATION_HEADER="add_header Onion-Location \"http://${ONION_HOSTNAME}\$request_uri\";"
else
export ONION_LOCATION_HEADER=""
fi
export CLEARNET_DOMAIN export CLEARNET_DOMAIN
envsubst '${CLEARNET_DOMAIN} ${ONION_LOCATION_HEADER}' \ envsubst '${CLEARNET_DOMAIN}' \
< "$template_path" \ < "$template_path" \
> "$output_path" > "$output_path"
@@ -40,6 +40,7 @@ location /pgadmin {
} }
location / { location / {
${ONION_LOCATION_HEADER}
add_header Referrer-Policy "no-referrer" always; add_header Referrer-Policy "no-referrer" always;
add_header Cache-Control "no-store" always; add_header Cache-Control "no-store" always;