map $http_upgrade $connection_upgrade { default upgrade; '' close; } upstream api { server $PROXY_BACKEND:$PROXY_PORT; } server { listen 80; # Serve static files from the /app directory location / { root /app; index index.html; try_files $uri $uri/ /index.html; include /etc/nginx/mime.types; } location ~ ^/(api|felicity-gql)(/|$) { proxy_pass http://api; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; # Enable WebSocket support for /felicity-gql proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }