# nginx site for a Docker-free Warmbly install: the two static frontends plus # reverse proxies for the API, the websocket, the tracking service, and the # forms service. # Replace example.com. Every server block reads one certificate covering all # six names from /etc/letsencrypt/live/app.example.com/, so issue it first # (certbot certonly --standalone ... --cert-name app.example.com) or nginx # refuses the site. The proxied services bind localhost, so nothing but nginx # is reachable. map $http_upgrade $connection_upgrade { default upgrade; '' close; } # Dashboard (web/dist) server { listen 443 ssl http2; server_name app.example.com; ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; root /opt/warmbly/web; index index.html; location / { # Security response headers. Repeated per location because nginx drops # inherited add_header directives in any block that declares its own. add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Content-Security-Policy "frame-ancestors 'none'; object-src 'none'; base-uri 'none'; form-action 'self'" always; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; try_files $uri $uri/ /index.html; } # Never cache the shell or the runtime config; hashed assets are immutable. location = /index.html { # Security response headers. Repeated per location because nginx drops # inherited add_header directives in any block that declares its own. add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Content-Security-Policy "frame-ancestors 'none'; object-src 'none'; base-uri 'none'; form-action 'self'" always; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header Cache-Control "no-store" always; } location = /config.js { # Security response headers. Repeated per location because nginx drops # inherited add_header directives in any block that declares its own. add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Content-Security-Policy "frame-ancestors 'none'; object-src 'none'; base-uri 'none'; form-action 'self'" always; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header Cache-Control "no-store" always; } location /assets/ { # Security response headers. Repeated per location because nginx drops # inherited add_header directives in any block that declares its own. add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Content-Security-Policy "frame-ancestors 'none'; object-src 'none'; base-uri 'none'; form-action 'self'" always; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header Cache-Control "public, max-age=31536000, immutable" always; } } # Admin panel (admin/dist) server { listen 443 ssl http2; server_name admin.example.com; ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; root /opt/warmbly/admin; index index.html; location / { # Security response headers. Repeated per location because nginx drops # inherited add_header directives in any block that declares its own. add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Content-Security-Policy "frame-ancestors 'none'; object-src 'none'; base-uri 'none'; form-action 'self'" always; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; try_files $uri $uri/ /index.html; } # Never cache the shell or the runtime config; hashed assets are immutable. location = /index.html { # Security response headers. Repeated per location because nginx drops # inherited add_header directives in any block that declares its own. add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Content-Security-Policy "frame-ancestors 'none'; object-src 'none'; base-uri 'none'; form-action 'self'" always; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header Cache-Control "no-store" always; } location = /config.js { # Security response headers. Repeated per location because nginx drops # inherited add_header directives in any block that declares its own. add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Content-Security-Policy "frame-ancestors 'none'; object-src 'none'; base-uri 'none'; form-action 'self'" always; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header Cache-Control "no-store" always; } location /assets/ { # Security response headers. Repeated per location because nginx drops # inherited add_header directives in any block that declares its own. add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Content-Security-Policy "frame-ancestors 'none'; object-src 'none'; base-uri 'none'; form-action 'self'" always; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; add_header Cache-Control "public, max-age=31536000, immutable" always; } } # Backend API (:8080). Set TRUSTED_PROXIES=127.0.0.1/32 in warmbly.env so the # backend believes X-Forwarded-For from this proxy. server { listen 443 ssl http2; server_name api.example.com; ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; client_max_body_size 50m; location / { proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1; 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 300s; } } # Realtime websocket (:4000). WEBSOCKET_URL=wss://ws.example.com/socket/websocket server { listen 443 ssl http2; server_name ws.example.com; ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; location / { add_header X-Content-Type-Options "nosniff" always; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; proxy_pass http://127.0.0.1:4000; 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-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 3600s; } } # Tracking (:3000). TRACKING_DOMAIN=t.example.com and # TRACKING_TRUSTED_PROXIES=127.0.0.1/32 in warmbly.env. # # A workspace that verifies its own tracking domain (t.acme.com CNAME -> # t.example.com) needs a server block and a certificate of its own here: # verification is a DNS check, so it passes while nginx still has no # certificate for the name and every link on it fails TLS. nginx has no # on-demand issuance; the backend answers GET /tls/authorize?domain= # with 204 or 403 if you script it. See the bare-metal guide. # # A root redirect (acme.io pointed here so visitors reach the company site) # is the same: add acme.io and www.acme.io to server_name here, with a # certificate, and keep Host $host. The dashboard reports "Not reaching # visitors" until nginx sends it on; a linked instance can have Warmbly Cloud # serve it instead. server { listen 443 ssl http2; server_name t.example.com; ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; # The service sends nosniff itself. No HSTS: customers' own domains land here too. location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } # Hosted forms (forms service :8090). Its own process, so form traffic never # touches the API origin: FORMS_DOMAIN=forms.example.com in warmbly.env makes # share links and embed codes point here, and TRUSTED_PROXIES=127.0.0.1/32 # lets the service rate-limit on the real visitor address. The service only # serves the public form routes and /health; there is no API to hide. server { listen 443 ssl http2; server_name forms.example.com; ssl_certificate /etc/letsencrypt/live/app.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/app.example.com/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; # The service sends nosniff, a referrer policy and HSTS itself, and each form its own CSP. location / { proxy_pass http://127.0.0.1:8090; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } server { listen 80; server_name app.example.com admin.example.com api.example.com ws.example.com t.example.com forms.example.com; return 301 https://$host$request_uri; }