Files
termanager2/docker/nginx/default.conf
Francesco Picone 426a95211d Revisione blocchi 2 e 3: file protetti, ripristino atomico, import sicuri
Blocco 2
- Esiti delle azioni Livewire come avvisi (trait Avvisa) invece di flash
  che comparivano alla pagina dopo.
- PDF, miniature e versioni dei territori non più serviti da nginx su
  /storage: TerritorioFileController con login, permessi e cache privata.
- Ripristino tutto o niente: verifica dell'archivio, una transazione con
  import, piantine, blocco account e scambio dei file annullabile.
- Backup formato 2 con piantine, storico PDF e area KML.
- Posto unico preso in un passo (Cache::lock) e rispettato anche da
  import XML e PDF.
- Import PDF da cartella: abbinamento corretto (1-A, 12 B, ambigui),
  caricamento a lotti, file non PDF ignorati, PDF sostituito nello storico.
- L'import XML elimina i file dei territori che non usa più; comando
  territori:file-orfani per quelli accumulati prima.

Blocco 3
- Password attuale richiesta al cambio volontario; AuthenticateSession
  chiude le sessioni aperte altrove.
- Niente nomi dei proclamatori in chiaro nel registro attività.
- Export XML senza remember_token; chi riceve l'hash dal file deve
  cambiare password.
- Campagne: ultimo giorno incluso, percentuale sui territori distinti.
- Coda: retry_after 960 s, stop_grace_period 16m, Redis volatile-lru,
  impostazioni rilette a ogni job.
- Azzeramento che cancella anche piantine, area KML e anteprime.
- Pulsanti profilo e menu che non si nascondevano; icona del sito.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 15:01:41 +02:00

126 lines
5.0 KiB
Plaintext

server {
listen 80 default_server;
server_name _;
root /var/www/html/public;
index index.php;
charset utf-8;
# NOTE: client_max_body_size is deliberately NOT set here.
#
# entrypoint.sh writes it to /etc/nginx/conf.d/upload-limit.conf from
# MAX_UPLOAD_MB, together with PHP's upload_max_filesize/post_max_size, so
# that one variable governs the whole chain. A value in this server block
# would override the generated one and silently reinstate the mismatch this
# arrangement exists to prevent — the symptom being a 413 with no body,
# returned after zero bytes, which leaves the browser's upload bar frozen
# and the page with nothing to report.
# Behind Dokploy's Traefik, the real client IP arrives in X-Forwarded-For.
real_ip_header X-Forwarded-For;
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 192.168.0.0/16;
real_ip_recursive on;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
# Vite emits content-hashed filenames, so these are safe to cache hard.
location /build/ {
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
try_files $uri =404;
}
# Territory files (PDFs, archived versions, thumbnails, map images) are NOT
# public: anyone could download /storage/territori-pdf/territorio-12-34.pdf
# without logging in, the names are guessable, and the public cache header
# below let Cloudflare keep them for a week. Logged-in users get them from
# TerritorioFileController, publishers from the expiring assignment link.
location ^~ /storage/territori- {
return 404;
}
# What is left on the public disk (the congregation logo).
location /storage/ {
expires 7d;
add_header Cache-Control "public";
try_files $uri =404;
}
error_page 404 /index.php;
location ~ ^/index\.php(/|$) {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
# Restores the port, which nginx's own fastcgi_params drops.
#
# Since nginx 1.26 the packaged fastcgi_params sets HTTP_HOST to $host
# instead of $http_host. $host carries the hostname only: a request to
# localhost:8090 reaches PHP as "localhost". Laravel then rebuilds the
# request URL without the port, while URL::forceRootUrl() (see
# AppServiceProvider) generates links WITH it — so every signed URL
# fails validation. Concretely: all Livewire file uploads answer 401,
# because the upload endpoint aborts on an invalid signature.
#
# Only bites when APP_URL carries a non-standard port, i.e. local
# development. In production APP_URL has no port and the two forms
# agree. Forwarding the raw header is safe here because trustHosts()
# in bootstrap/app.php already rejects any Host that is not APP_URL's,
# localhost or 127.0.0.1.
fastcgi_param HTTP_HOST $http_host;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_hide_header X-Powered-By;
# PDF generation and ZIP imports can outrun the default 60s.
fastcgi_read_timeout 300;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
# Set server-side, NOT taken from the client's header: honouring a
# client-supplied X-Forwarded-Proto would let an attacker declare the
# connection plaintext and skew signed-URL validation and secure-cookie
# decisions. The value is written by the entrypoint from APP_URL's
# scheme (see /etc/nginx/conf.d/forwarded-proto.conf) — https in
# production behind Traefik, http for local plain-HTTP development.
fastcgi_param HTTP_X_FORWARDED_PROTO $app_forwarded_proto;
# X-Forwarded-Port is deliberately NOT set here. nginx already passes
# the incoming header through as HTTP_X_FORWARDED_PORT, and Traefik
# sends the real public port; overriding it with $server_port (always
# 80 inside the container) would corrupt generated URLs.
internal;
}
# Any other .php file is not a valid entrypoint — Laravel routes everything
# through index.php. This blocks execution of uploaded/stray scripts.
location ~ \.php$ {
return 404;
}
location ~ /\.(?!well-known).* {
deny all;
}
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css application/json application/javascript
text/xml application/xml image/svg+xml;
}