Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions core/services/helper/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,16 @@ def setup_nginx_route(metadata: ServiceMetadata, port: int) -> bool:
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Add proxy_http_version 1.1; in the WebSocket location to ensure Upgrade works reliably.

Without explicitly setting HTTP/1.1 in this location block, some setups can fall back to HTTP/1.0 semantics and ignore the Upgrade/Connection headers, leading to intermittent WebSocket failures. Please add:

proxy_http_version 1.1;

inside location /extensionv2/{name}/ws.

}}

location /extensionv2/{name}/ws {{
proxy_pass http://127.0.0.1:{port}/ws;
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;
}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be interesting to have the following lines for CORS conflicts.
proxy_hide_header Access-Control-Allow-Origin;
include cors.conf;

Add the following line for websocket upgrade:
proxy_http_version 1.1;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @patrickelectric ,

Thanks for the review.

It would be interesting to have the following lines for CORS conflicts. proxy_hide_header Access-Control-Allow-Origin; include cors.conf;

Do you want me to include this in the default extension v2 location or just for the websocket location block?

And do you think I should make the websocket location block nested inside the other block? To reduce duplicate headers?

Add the following line for websocket upgrade:
proxy_http_version 1.1;

Will do!

"""
filename = f"/home/pi/tools/nginx/extensions/{name}.conf"
Path.mkdir(Path("/home/pi/tools/nginx/extensions/"), parents=True, exist_ok=True)
Expand Down
Loading