Skip to content

Commit 35eff1c

Browse files
committed
Fix proxy redirect losing /api/ prefix and port on trailing-slash redirects
FastAPI issues 307 redirects to add trailing slashes (e.g. /editor/create_flow → /editor/create_flow/). When proxy_set_header Host $host was used, the redirect Location header used the external hostname without port (http://192.168.50.176/editor/create_flow/), bypassing both the /api/ prefix and the correct port (8080). Fix by removing the Host override so nginx uses the default $proxy_host (flowfile-core:63578). Now the backend's redirect points to the internal host, and nginx's built-in proxy_redirect default correctly rewrites it to http://<external-host>:8080/api/editor/create_flow/. Also remove premature WebSocket headers (Connection: "upgrade" was being sent on all requests) and add X-Forwarded-Host so the backend can access the original host if needed. https://claude.ai/code/session_01HtZJr4MnVSYw8MGuqgKiTq
1 parent e97e7c5 commit 35eff1c

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

flowfile_frontend/nginx.conf

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,24 @@ server {
99
location /api/ {
1010
proxy_pass http://flowfile-core:63578/;
1111
proxy_http_version 1.1;
12-
proxy_set_header Host $host;
12+
13+
# Do NOT override Host — let nginx use the default $proxy_host
14+
# (flowfile-core:63578). This is critical because FastAPI may issue
15+
# trailing-slash redirects using the Host header. With the default
16+
# $proxy_host, the redirect Location points to the internal host,
17+
# and nginx's built-in proxy_redirect (default) correctly rewrites
18+
# it back to the external URL with the /api/ prefix and correct port.
1319
proxy_set_header X-Real-IP $remote_addr;
1420
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
1521
proxy_set_header X-Forwarded-Proto $scheme;
22+
proxy_set_header X-Forwarded-Host $http_host;
1623
proxy_read_timeout 300s;
1724
proxy_send_timeout 300s;
1825

1926
# SSE support for log streaming
2027
proxy_buffering off;
2128
proxy_cache off;
2229

23-
# WebSocket support (for future real-time features)
24-
proxy_set_header Upgrade $http_upgrade;
25-
proxy_set_header Connection "upgrade";
26-
2730
# Allow large file uploads
2831
client_max_body_size 500M;
2932
}

0 commit comments

Comments
 (0)