Aggiunge proxy edge con pagina di cortesia e rilascio a downtime minimo.

NPM punta a nginx locale su :3000 che resta attivo durante il restart Rails; nuovo script release_production.sh esegue migrate, build e deploy in ordine.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-13 09:31:36 +02:00
parent 208664848e
commit 949a0a01fb
6 changed files with 316 additions and 21 deletions

View File

@@ -0,0 +1,85 @@
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# DNS Docker: risolve di nuovo l'IP di rails dopo ogni recreate container.
resolver 127.0.0.11 valid=5s ipv6=off;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name _;
client_max_body_size 20M;
set $rails_backend rails:3000;
location = /edge-health {
access_log off;
add_header Content-Type text/plain;
return 200 "ok\n";
}
# Health check ops: pass-through senza pagina di cortesia.
location = /up {
proxy_pass http://$rails_backend;
proxy_connect_timeout 2s;
proxy_read_timeout 10s;
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 $scheme;
}
location = /up/deep {
proxy_pass http://$rails_backend;
proxy_connect_timeout 2s;
proxy_read_timeout 30s;
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 $scheme;
}
location /cable {
proxy_pass http://$rails_backend;
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 $scheme;
proxy_read_timeout 86400;
proxy_connect_timeout 2s;
error_page 502 503 504 = @maintenance;
}
location / {
proxy_pass http://$rails_backend;
proxy_connect_timeout 2s;
proxy_read_timeout 120s;
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 $scheme;
error_page 502 503 504 = @maintenance;
}
location @maintenance {
internal;
root /usr/share/nginx/maintenance;
try_files /index.html =503;
add_header Retry-After 15 always;
add_header Cache-Control "no-store" always;
}
}
}