Repository navigation
Expand file tree
/
Copy pathnginx-dev.conf
More file actions
109 lines (91 loc) · 4.69 KB
/
Copy pathnginx-dev.conf
File metadata and controls
109 lines (91 loc) · 4.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Mirrors the production nginx.conf worker sizing so a local restart
# exercises the same events block; see the comment there for the why.
worker_processes 2;
worker_rlimit_nofile 32768;
events {
worker_connections 8192;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Sanitize token query param from logs
map $request_uri $sanitized_request_uri {
"~^(?<prefix>[^?]*\?)(?<before>.*)token=[^&]*(?<after>.*)$" "$prefix${before}token=[REDACTED]$after";
default $request_uri;
}
log_format main '$remote_addr [$time_local] "$request_method $sanitized_request_uri $server_protocol" '
'$status $body_bytes_sent "$http_referer"';
access_log /dev/stdout main;
error_log /dev/stderr warn;
# SSL certificates (mkcert)
ssl_certificate /etc/nginx/certs/cert.pem;
ssl_certificate_key /etc/nginx/certs/key.pem;
# Support subdomain proxy — *.support.my.localtest.me
server {
listen 443 ssl;
server_name ~^.+\.support\..*;
location / {
rewrite ^(.*)$ /support-proxy$1 break;
proxy_pass http://host.containers.internal:8080;
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_set_header X-Forwarded-Host $host;
# WebSocket support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Long timeouts for support sessions
proxy_connect_timeout 24h;
proxy_send_timeout 24h;
proxy_read_timeout 24h;
}
}
# Main app — my.localtest.me
server {
listen 443 ssl default_server;
server_name _;
# Security headers (dev mirror of proxy/nginx.conf so CSP breakage
# shows up locally first; main-app server only, the *.support.*
# server above proxies third-party UIs). Differences from the
# deployed policy: wildcard *.logto.app (dev tenants) and ws: in
# connect-src for the Vite HMR socket; the Kapa AI widget origins
# (prod-only in the deployed policy) so it can be tried locally with
# VITE_KAPA_WEBSITE_ID. No HSTS: localtest.me only.
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;
add_header Content-Security-Policy "default-src 'self'; script-src 'self' https://widget.kapa.ai https://www.google.com https://www.gstatic.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob: https://*.logto.app https://id.nethesis.it https://qa.id.nethesis.it https://www.google.com https://*.gstatic.com; font-src 'self' data:; connect-src 'self' ws: wss: https://*.logto.app https://id.nethesis.it https://qa.id.nethesis.it https://nethshop2.nethesis.it https://my.staging.nethspot.com https://formazione.nethesis.it https://proxy.kapa.ai https://metrics.kapa.ai https://www.google.com; frame-src 'self' https://www.google.com; worker-src 'self' blob:; object-src 'none'; base-uri 'self'; frame-ancestors 'self'; form-action 'self' https://*.logto.app https://id.nethesis.it https://qa.id.nethesis.it" always;
# Backend API
location /api/ {
proxy_pass http://host.containers.internal:8080;
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_set_header X-Forwarded-Host $host;
# WebSocket support (terminal, etc.)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Long timeouts for WebSocket terminal sessions
proxy_connect_timeout 30s;
proxy_send_timeout 24h;
proxy_read_timeout 24h;
}
# Frontend (Vite dev server)
location / {
proxy_pass http://host.containers.internal:5173;
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_set_header X-Forwarded-Host $host;
# WebSocket support (Vite HMR)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
}