Embedded variables from ngx_http_core_module and websocket connections

Sergey A. Osokin osa at freebsd.org.ru
Wed Jul 21 10:48:35 UTC 2021


Hi Dorin,

hope you're doing well.

On Tue, Jul 20, 2021 at 12:39:51PM +0200, Dorin RuV wrote:
> Hi everybody,
> 
> I'm currently having an issue with nginx which I cannot get to the bottom
> of.
> 
> I'm using nginx as a reverse proxy/load balancer in front of Kubernetes.
> I'm trying to set up Websocket connections with an app running in
> Kubernetes, but there are some problems. I have followed the "more
> sophisticated" example from https://nginx.org/en/docs/http/websocket.html.
> 
> The configuration more or less looks like:
> 
> "http {
> 
>   map $http_upgrade $connection_upgrade {
>     default upgrade;
>     '' close;
>   }      # building the connection_upgrade variable based on $http_upgrade
> ......
> 
> 
> server{
>   listen 443 ssl http2;
>   location / {
>     proxy_http_version 1.1;
>     proxy_set_header Upgrade $http_upgrade;
>     proxy_set_header Connection $connection_upgrade;
>   }
> ....
> "
> There is also a server { listen 80 } directive there which simply redirects
> to https.
> 
> If I configure "proxy_set_header Upgrade  Websocket" and "Connection
> Upgrade", everything works as intended. It seems though that the
> $http_upgrade variable is seen as empty, even though tcpdump confirms the
> fact that the Upgrade header is correctly sent to Nginx by the client
> request. Can somebody please point me towards what could reset this
> variable or why is it unavailable? I'm thinking some scope issues but I
> have no idea how to debug.

Is there a chance to use debug log feature,
https://nginx.org/en/docs/debugging_log.html,
and reproduce the issue with "working" and "non-working" configuration
files.

-- 
Sergey Osokin


More information about the nginx mailing list