Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨(marsha) configure nginx to handle websocket #713

Merged
merged 1 commit into from
Jan 28, 2022
Merged

Conversation

lunika
Copy link
Member

@lunika lunika commented Jan 10, 2022

Purpose

Marsha supports websocket. We need to configure Nginx to manage this
connection. All websockets begin with /ws/, a new location block is
created responsible to deal with the Connection and Upgrade header

Proposal

  • configure nginx to manage websocket

@@ -15,6 +15,8 @@ marsha_nginx_status_endpoint: "/__status__"
marsha_nginx_admin_ip_whitelist: []
marsha_nginx_bypass_htaccess_ip_whitelist: []
marsha_nginx_static_cache_expires: "1M"
marsha_nginx_websocket_proxy_read_timeout: 86400
marsha_nginx_websocket_proxy_send_timeout: 86400
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment explaining why a 24h read/send timeout?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I can

Copy link
Member Author

Choose a reason for hiding this comment

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

After tests, keeping the default value still work. The ping/pong implementation keeps alive the connection while the client is connected. I will remove all timeout but I keep the location block in the nginx configuration to not mix webstocket and http requests.

Comment on lines 17 to 18
nginx.ingress.kubernetes.io/proxy-read-timeout: "{{ marsha_nginx_websocket_proxy_read_timeout }}"
nginx.ingress.kubernetes.io/proxy-send-timeout: "{{ marsha_nginx_websocket_proxy_send_timeout }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

This configuration will impact all connections/locations received by nginx, No side effect is expected?

Copy link
Member Author

Choose a reason for hiding this comment

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

By the ingress. And after in the nginx deploy with marsha we can reconfigure a lower timeout if needed. The first closing the connection will close the connection for all other proxies.

proxy_read_timeout {{ marsha_nginx_websocket_proxy_read_timeout }};
proxy_send_timeout {{ marsha_nginx_websocket_proxy_send_timeout }};
}

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO you don't need a new location if you allow to upgrade connections for the / location.

Copy link
Member Author

@lunika lunika Jan 11, 2022

Choose a reason for hiding this comment

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

This new location is needed to isolate websocket connection from others. For a classic http connection we don't want to allow a so big timeout. Only for websocket. So we must add this new location dedicated to websocket.

Copy link
Member Author

Choose a reason for hiding this comment

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

One other argument to keep this location block is http/2. The UvicornWorker is able to handle http2 and I see that browsers compatible are using this protocol

CHANGELOG.md Outdated Show resolved Hide resolved
@lunika
Copy link
Member Author

lunika commented Jan 11, 2022

@jmaupetit ready for a new review

Copy link
Contributor

@jmaupetit jmaupetit left a comment

Choose a reason for hiding this comment

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

CHANGELOG.md Outdated
@@ -8,6 +8,10 @@ Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased

### Added

- Marsha: configure nginx to handle websockets
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Marsha: configure nginx to handle websockets
- Marsha: configure nginx to handle websockets in a dedicated location

@lunika lunika changed the title ✨(marsha) configure nginx to manage websocket ✨(marsha) configure nginx to handle websocket Jan 11, 2022
@lunika lunika force-pushed the marsha-websocket branch 2 times, most recently from be1268e to db1bb68 Compare January 13, 2022 08:45
Marsha supports websocket. We need to configure Nginx to handle this
connection. All websockets begin with `/ws/`, a new location block is
created responsible to deal with the Connection and Upgrade header.
@lunika lunika merged commit 6a793af into master Jan 28, 2022
@lunika lunika deleted the marsha-websocket branch January 28, 2022 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants