Reverse Proxy¶
LANCache Manager runs fine behind nginx. HTTPS is recommended.
Tip
Fronting the manager with a proxy? Also set Security__KnownProxyNetworks (see Security) so client IPs are reported correctly.
Single origin (recommended)¶
Serve the UI and API from the same hostname. Cookies stay first-party, CORS is a non-issue.
server {
listen 443 ssl http2;
server_name lancache.example.com;
ssl_certificate /etc/letsencrypt/live/lancache.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/lancache.example.com/privkey.pem;
# Max request body size - raise it if large uploads (like database imports) fail with 413
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_set_header X-Forwarded-Host $host;
# SignalR (WebSockets)
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 600s; # Headroom for slow periods; SignalR's 10s keepalives normally keep the socket alive
}
}
server {
listen 80;
server_name lancache.example.com;
return 301 https://$host$request_uri;
}
Separate API origin (only if you must)¶
If the UI and API live on different hostnames:
- Build the UI with
VITE_API_URL=https://api.lancache.example.com. - List the UI origin in
Security__AllowedOriginsso CORS allows it with credentials. - Keep both hostnames under the same registrable domain, as in this example. LANCache Manager issues
SameSite=Laxcookies, and a browser only sends those when the two hostnames share a site - an API on an entirely different domain cannot use cookie sign-in.
server {
listen 443 ssl http2;
server_name api.lancache.example.com;
ssl_certificate /etc/letsencrypt/live/api.lancache.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.lancache.example.com/privkey.pem;
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_set_header X-Forwarded-Host $host;
# SignalR (WebSockets)
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 600s; # Headroom for slow periods; SignalR's 10s keepalives normally keep the socket alive
}
}