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 2021-02-02 22:20:46 +01:00 committed by GitHub
parent f2aa59297d
commit 5f8931c231
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -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', [

View File

@ -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';