Add nginx reverse proxy for VM deployment

Configure nginx to proxy API and WebSocket requests to backend.
This allows the frontend to work on VMs without hardcoded localhost URLs.

Changes:
- nginx.conf: Added proxy rules for /api/, /ws, and /health
- client.ts: Use relative URLs in production mode
- websocket.ts: Dynamically construct WebSocket URL based on current host

This fixes ERR_BLOCKED_BY_CLIENT and connection issues on VMs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
felix.zoesch
2025-12-15 16:03:44 +01:00
parent 267425806d
commit e19f500fb0
3 changed files with 49 additions and 2 deletions

View File

@@ -9,6 +9,36 @@ server {
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# Proxy API requests to backend
location /api/ {
proxy_pass http://backend:8000/api/;
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 WebSocket connections to backend
location /ws {
proxy_pass http://backend:8000/ws;
proxy_http_version 1.1;
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;
proxy_read_timeout 86400;
}
# Proxy health check to backend
location /health {
proxy_pass http://backend:8000/health;
proxy_http_version 1.1;
proxy_set_header Host $host;
}
location / {
try_files $uri $uri/ /index.html;
}