-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsys-manager.nginx.conf
More file actions
94 lines (79 loc) · 3.74 KB
/
Copy pathsys-manager.nginx.conf
File metadata and controls
94 lines (79 loc) · 3.74 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
server {
listen 80;
server_name dashboard.example.com;
# Redirect all HTTP traffic to HTTPS
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
server_name dashboard.example.com;
# SSL Certificates (managed by Certbot)
ssl_certificate /etc/letsencrypt/live/dashboard.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/dashboard.example.com/privkey.pem;
# Recommended SSL Settings
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
# --- Hardening ---
server_tokens off; # don't leak the nginx version
client_max_body_size 25m; # cap request bodies (uploads / config POSTs)
# HSTS: pin HTTPS for a year. Only safe once every subdomain is HTTPS;
# drop includeSubDomains otherwise.
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# The app sets its own Content-Security-Policy where it matters; not overridden here.
# --- Rate limiting (optional, opt-in) ---
# `limit_req_zone` must be declared in the http{} context, so it can't live
# in this server snippet. To enable, add to nginx.conf's http{} block:
# limit_req_zone $binary_remote_addr zone=sfauth:10m rate=10r/s;
# then uncomment the `limit_req` line in the /(api|auth)/ block below.
# --- Next.js Frontend ---
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# Pass real client IP
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;
}
# --- Rust API & Auth Routes ---
location ~ ^/(api|auth)/ {
# limit_req zone=sfauth burst=20 nodelay; # see rate-limit note above
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
# Pass real client IP
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;
}
# --- WebSocket Connections (UI only) ---
# `/agent/ws` is NO LONGER proxied here. Agents now connect
# directly to the server's mutual-TLS listener (default :8443,
# AGENT_MTLS_PORT) and present a client certificate. Only the
# browser UI WebSocket stays on this nginx-terminated path —
# browsers can't present client certs and /ui/ws authenticates via
# Origin validation + session cookie.
location ~ ^/ui/ws {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
# Crucial headers for WebSocket Upgrade
proxy_set_header Upgrade $http_upgrade;
proxy_set_header 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;
# Prevent Nginx from closing the WebSocket connection too quickly
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
}