nginx module: add option for proxying websocket requests
This commit is contained in:
parent
530282eebe
commit
65c2203ffc
@ -92,6 +92,11 @@ let
|
||||
include ${recommendedProxyConfig};
|
||||
''}
|
||||
|
||||
# $connection_upgrade is used for websocket proxying
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
''' close;
|
||||
}
|
||||
client_max_body_size ${cfg.clientMaxBodySize};
|
||||
|
||||
server_tokens ${if cfg.serverTokens then "on" else "off"};
|
||||
@ -213,6 +218,11 @@ let
|
||||
proxy_pass ${config.proxyPass};
|
||||
${optionalString cfg.recommendedProxySettings "include ${recommendedProxyConfig};"}
|
||||
''}
|
||||
${optionalString config.proxyWebsockets ''
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
''}
|
||||
${optionalString (config.index != null) "index ${config.index};"}
|
||||
${optionalString (config.tryFiles != null) "try_files ${config.tryFiles};"}
|
||||
${optionalString (config.root != null) "root ${config.root};"}
|
||||
|
@ -19,6 +19,15 @@ with lib;
|
||||
'';
|
||||
};
|
||||
|
||||
proxyWebsockets = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = ''
|
||||
Whether to supporty proxying websocket connections with HTTP/1.1.
|
||||
'';
|
||||
};
|
||||
|
||||
index = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
|
Loading…
Reference in New Issue
Block a user