Browse Source

Improve Connection header for WebSocket reverse proxy (#217)

* Improve Connection header for WebSocket reverse proxy

reference: https://nginx.org/en/docs/http/websocket.html

* Move map to http context
pull/219/head
Michael Krickl 4 years ago committed by GitHub
parent
commit
5f8931c231
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/nginxconfig/generators/conf/nginx.conf.js
  2. 2
      src/nginxconfig/generators/conf/proxy.conf.js

9
src/nginxconfig/generators/conf/nginx.conf.js

@ -190,6 +190,15 @@ export default (domains, global) => {
}
}
// Connection header for WebSocket reverse proxy
if (domains.some(d => d.reverseProxy.reverseProxy.computed)) {
config.http.push(['# Connection header for WebSocket reverse proxy', '']);
config.http.push(['map $http_upgrade $connection_upgrade', {
'default': 'upgrade',
'""': 'close',
}]);
}
// Configs!
config.http.push(['# Load configs', '']);
config.http.push(['include', [

2
src/nginxconfig/generators/conf/proxy.conf.js

@ -32,7 +32,7 @@ export default global => {
config['# Proxy headers'] = '';
config['proxy_set_header Upgrade'] = '$http_upgrade';
config['proxy_set_header Connection'] = '"upgrade"';
config['proxy_set_header Connection'] = '$connection_upgrade';
config['proxy_set_header Host'] = '$host';
config['proxy_set_header X-Real-IP'] = '$remote_addr';
config['proxy_set_header X-Forwarded-For'] = '$proxy_add_x_forwarded_for';

Loading…
Cancel
Save