Welcome! Log In Create A New Profile

Advanced

Re: Embedded variables from ngx_http_core_module and websocket connections

Dorin RuV
July 21, 2021 09:48AM
Hi Sergey,

Thank you for lending a hand!

I have enabled debug and here are two different calls to the backend:

1. It worked (The nginx config contains a hard-coded "Connection Upgrade"
and "Upgrade Websocket" proxy_set_headers)

"2021/07/21 13:36:43 [debug] 1#1: bind() 0.0.0.0:8060 #6
2021/07/21 13:36:43 [debug] 1#1: bind() 0.0.0.0:8063 #7
2021/07/21 13:36:43 [notice] 1#1: using the "epoll" event method
2021/07/21 13:36:43 [debug] 1#1: counter: 00007F9A0E809080, 1
2021/07/21 13:36:43 [notice] 1#1: nginx/1.18.0
2021/07/21 13:36:43 [notice] 1#1: OS: Linux 4.14.239-1626564138
2021/07/21 13:36:43 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2021/07/21 13:36:43 [debug] 1#1: write: 8, 00007FFC29515792, 2, 0
2021/07/21 13:36:43 [debug] 1#1: setproctitle: "nginx: master process
nginx-debug -c /usr/local/nginx/conf/nginx.conf -g daemon off;"
2021/07/21 13:36:43 [notice] 1#1: start worker processes
2021/07/21 13:36:43 [debug] 1#1: channel 3:8
2021/07/21 13:36:43 [notice] 1#1: start worker process 8
2021/07/21 13:36:43 [debug] 1#1: channel 9:10
2021/07/21 13:36:43 [debug] 8#8: add cleanup: 00007F9A0E80F8A8
2021/07/21 13:36:43 [debug] 8#8: malloc: 00007F9A0E89B090:8
2021/07/21 13:36:43 [notice] 1#1: start worker process 9
2021/07/21 13:36:43 [debug] 1#1: pass channel s:1 pid:9 fd:9 to s:0 pid:8
fd:3
2021/07/21 13:36:43 [debug] 1#1: channel 11:12
2021/07/21 13:36:43 [debug] 9#9: add cleanup: 00007F9A0E80F8A8
2021/07/21 13:36:43 [debug] 9#9: malloc: 00007F9A0E89B090:8
2021/07/21 13:36:43 [notice] 1#1: start worker process 10
2021/07/21 13:36:43 [debug] 1#1: pass channel s:2 pid:10 fd:11 to s:0 pid:8
fd:3
2021/07/21 13:36:43 [debug] 8#8: notify eventfd: 10
2021/07/21 13:36:43 [debug] 1#1: pass channel s:2 pid:10 fd:11 to s:1 pid:9
fd:9
2021/07/21 13:36:43 [debug] 8#8: eventfd: 11
2021/07/21 13:36:43 [debug] 1#1: channel 13:14
2021/07/21 13:36:43 [debug] 10#10: add cleanup: 00007F9A0E80F8A8
2021/07/21 13:36:43 [debug] 10#10: malloc: 00007F9A0E89B090:8
2021/07/21 13:36:43 [debug] 9#9: notify eventfd: 12
2021/07/21 13:36:43 [debug] 8#8: testing the EPOLLRDHUP flag: success
2021/07/21 13:36:43 [debug] 9#9: eventfd: 13
2021/07/21 13:36:43 [debug] 8#8: malloc: 00007F9A0E88A450:6144
2021/07/21 13:36:43 [debug] 8#8: malloc: 00007F9A0DDCB460:237568
2021/07/21 13:36:43 [notice] 1#1: start worker process 11
2021/07/21 13:36:43 [debug] 8#8: malloc: 00007F9A0DDB2470:98304
2021/07/21 13:36:43 [debug] 9#9: testing the EPOLLRDHUP flag: success
2021/07/21 13:36:43 [debug] 1#1: pass channel s:3 pid:11 fd:13 to s:0 pid:8
fd:3
2021/07/21 13:36:43 [debug] 1#1: pass channel s:3 pid:11 fd:13 to s:1 pid:9
fd:9
2021/07/21 13:36:43 [debug] 1#1: pass channel s:3 pid:11 fd:13 to s:2
pid:10 fd:11
2021/07/21 13:36:43 [debug] 9#9: malloc: 00007F9A0E88A450:6144
2021/07/21 13:36:43 [debug] 1#1: sigsuspend
2021/07/21 13:36:43 [debug] 9#9: malloc: 00007F9A0DDCB460:237568
2021/07/21 13:36:43 [debug] 8#8: malloc: 00007F9A0DD99480:98304
2021/07/21 13:36:43 [debug] 10#10: notify eventfd: 14
2021/07/21 13:36:43 [debug] 9#9: malloc: 00007F9A0DDB2470:98304
2021/07/21 13:36:43 [debug] 10#10: eventfd: 15
2021/07/21 13:36:43 [debug] 10#10: testing the EPOLLRDHUP flag: success
2021/07/21 13:36:43 [debug] 9#9: malloc: 00007F9A0DD99480:98304
2021/07/21 13:36:43 [debug] 10#10: malloc: 00007F9A0E88A450:6144
2021/07/21 13:36:43 [debug] 10#10: malloc: 00007F9A0DDCB460:237568
2021/07/21 13:36:43 [debug] 10#10: malloc: 00007F9A0DDB2470:98304
2021/07/21 13:36:43 [debug] 8#8: epoll add event: fd:8 op:1 ev:00002001
2021/07/21 13:36:43 [debug] 8#8: setproctitle: "nginx: worker process"
2021/07/21 13:36:43 [debug] 8#8: worker cycle
2021/07/21 13:36:43 [debug] 8#8: epoll timer: -1
2021/07/21 13:36:43 [debug] 10#10: malloc: 00007F9A0DD99480:98304
2021/07/21 13:36:43 [debug] 8#8: epoll: fd:8 ev:0001 d:00007F9A0DDCB630
2021/07/21 13:36:43 [debug] 8#8: channel handler
2021/07/21 13:36:43 [debug] 8#8: channel: 32
2021/07/21 13:36:43 [debug] 9#9: epoll add event: fd:10 op:1 ev:00002001
2021/07/21 13:36:43 [debug] 8#8: channel command: 1
2021/07/21 13:36:43 [debug] 9#9: setproctitle: "nginx: worker process"
2021/07/21 13:36:43 [debug] 8#8: get channel s:1 pid:9 fd:3
2021/07/21 13:36:43 [debug] 9#9: worker cycle
2021/07/21 13:36:43 [debug] 9#9: epoll timer: -1
2021/07/21 13:36:43 [debug] 8#8: channel: 32
2021/07/21 13:36:43 [debug] 8#8: channel command: 1
2021/07/21 13:36:43 [debug] 8#8: get channel s:2 pid:10 fd:12
2021/07/21 13:36:43 [debug] 9#9: epoll: fd:10 ev:0001 d:00007F9A0DDCB630
2021/07/21 13:36:43 [debug] 9#9: channel handler
2021/07/21 13:36:43 [debug] 8#8: channel: 32
2021/07/21 13:36:43 [debug] 8#8: channel command: 1
2021/07/21 13:36:43 [debug] 9#9: channel: 32
2021/07/21 13:36:43 [debug] 8#8: get channel s:3 pid:11 fd:13
2021/07/21 13:36:43 [debug] 9#9: channel command: 1
2021/07/21 13:36:43 [debug] 9#9: get channel s:2 pid:10 fd:8
2021/07/21 13:36:43 [debug] 8#8: channel: -2
2021/07/21 13:36:43 [debug] 8#8: timer delta: 21
2021/07/21 13:36:43 [debug] 9#9: channel: 32
2021/07/21 13:36:43 [debug] 8#8: worker cycle
2021/07/21 13:36:43 [debug] 9#9: channel command: 1
2021/07/21 13:36:43 [debug] 8#8: epoll timer: -1
2021/07/21 13:36:43 [debug] 9#9: get channel s:3 pid:11 fd:9
2021/07/21 13:36:43 [debug] 10#10: epoll add event: fd:12 op:1 ev:00002001
2021/07/21 13:36:43 [debug] 9#9: channel: -2
2021/07/21 13:36:43 [debug] 10#10: setproctitle: "nginx: worker process"
2021/07/21 13:36:43 [debug] 9#9: timer delta: 21
2021/07/21 13:36:43 [debug] 10#10: worker cycle
2021/07/21 13:36:43 [debug] 9#9: worker cycle
2021/07/21 13:36:43 [debug] 10#10: epoll timer: -1
2021/07/21 13:36:43 [debug] 9#9: epoll timer: -1
2021/07/21 13:36:43 [debug] 10#10: epoll: fd:12 ev:0001 d:00007F9A0DDCB630
2021/07/21 13:36:43 [debug] 10#10: channel handler
2021/07/21 13:36:43 [debug] 10#10: channel: 32
2021/07/21 13:36:43 [debug] 10#10: channel command: 1
2021/07/21 13:36:43 [debug] 10#10: get channel s:3 pid:11 fd:8
2021/07/21 13:36:43 [debug] 10#10: channel: -2
2021/07/21 13:36:43 [debug] 11#11: add cleanup: 00007F9A0E80F8A8
2021/07/21 13:36:43 [debug] 10#10: timer delta: 21
2021/07/21 13:36:43 [debug] 10#10: worker cycle
2021/07/21 13:36:43 [debug] 10#10: epoll timer: -1
2021/07/21 13:36:43 [debug] 11#11: malloc: 00007F9A0E89B090:8
2021/07/21 13:36:43 [debug] 11#11: notify eventfd: 16
2021/07/21 13:36:43 [debug] 11#11: eventfd: 17
2021/07/21 13:36:43 [debug] 11#11: testing the EPOLLRDHUP flag: success
2021/07/21 13:36:43 [debug] 11#11: malloc: 00007F9A0E88A450:6144
2021/07/21 13:36:43 [debug] 11#11: malloc: 00007F9A0DDCB460:237568
2021/07/21 13:36:43 [debug] 11#11: malloc: 00007F9A0DDB2470:98304
2021/07/21 13:36:43 [debug] 11#11: malloc: 00007F9A0DD99480:98304
2021/07/21 13:36:43 [debug] 11#11: epoll add event: fd:14 op:1 ev:00002001
2021/07/21 13:36:43 [debug] 11#11: setproctitle: "nginx: worker process"
2021/07/21 13:36:43 [debug] 11#11: worker cycle
2021/07/21 13:36:43 [debug] 11#11: epoll timer: -1
2021/07/21 13:36:48 [debug] 8#8: epoll: fd:7 ev:0001 d:00007F9A0DDCB548
2021/07/21 13:36:48 [debug] 8#8: timer delta: 5334
2021/07/21 13:36:48 [debug] 8#8: worker cycle
2021/07/21 13:36:48 [debug] 8#8: epoll timer: 60000
2021/07/21 13:36:48 [debug] 8#8: epoll: fd:14 ev:0001 d:00007F9A0DDCB718
2021/07/21 13:36:48 [debug] 8#8: timer delta: 9
2021/07/21 13:36:48 [debug] 8#8: worker cycle
2021/07/21 13:36:48 [debug] 8#8: epoll timer: 59991
2021/07/21 13:36:48 [debug] 8#8: epoll: fd:14 ev:0001 d:00007F9A0DDCB718
2021/07/21 13:36:48 [debug] 8#8: timer delta: 3
2021/07/21 13:36:48 [debug] 8#8: worker cycle
2021/07/21 13:36:48 [debug] 8#8: epoll timer: 59988
2021/07/21 13:36:48 [debug] 8#8: epoll: fd:14 ev:0001 d:00007F9A0DDCB718
2021/07/21 13:36:48 [debug] 8#8: shmtx lock
2021/07/21 13:36:48 [debug] 8#8: slab alloc: 191 slot: 5
2021/07/21 13:36:48 [debug] 8#8: slab alloc: 00007F9A0DE18000
2021/07/21 13:36:48 [debug] 8#8: slab alloc: 128 slot: 4
2021/07/21 13:36:48 [debug] 8#8: slab alloc: 00007F9A0DE16080
2021/07/21 13:36:48 [debug] 8#8: shmtx unlock
2021/07/21 13:36:48 [debug] 8#8: shmtx lock
2021/07/21 13:36:48 [debug] 8#8: slab alloc: 191 slot: 5
2021/07/21 13:36:48 [debug] 8#8: slab alloc: 00007F9A0DE18100
2021/07/21 13:36:48 [debug] 8#8: slab alloc: 128 slot: 4
2021/07/21 13:36:48 [debug] 8#8: slab alloc: 00007F9A0DE16100
2021/07/21 13:36:48 [debug] 8#8: shmtx unlock
2021/07/21 13:36:48 [debug] 8#8: malloc: 00007F9A0DD4A5D0:262144
2021/07/21 13:36:48 [debug] 8#8: timer delta: 6
2021/07/21 13:36:48 [debug] 8#8: worker cycle
2021/07/21 13:36:48 [debug] 8#8: epoll timer: 120000
2021/07/21 13:36:48 [debug] 8#8: epoll: fd:15 ev:0004 d:00007F9A0DDCB800
2021/07/21 13:36:48 [debug] 8#8: timer delta: 1
2021/07/21 13:36:48 [debug] 8#8: worker cycle
2021/07/21 13:36:48 [debug] 8#8: epoll timer: 120000
2021/07/21 13:36:48 [debug] 8#8: epoll: fd:14 ev:0001 d:00007F9A0DDCB718
2021/07/21 13:36:48 [debug] 8#8: timer delta: 0
2021/07/21 13:36:48 [debug] 8#8: worker cycle
2021/07/21 13:36:48 [debug] 8#8: epoll timer: 120000
2021/07/21 13:36:49 [debug] 8#8: epoll: fd:15 ev:0005 d:00007F9A0DDCB800
2021/07/21 13:36:49 [debug] 8#8: timer delta: 1
2021/07/21 13:36:49 [debug] 8#8: worker cycle
2021/07/21 13:36:49 [debug] 8#8: epoll timer: 119999
2021/07/21 13:37:04 [debug] 8#8: epoll: fd:14 ev:2001 d:00007F9A0DDCB718
10.197.96.163 - - [21/Jul/2021:13:37:04 +0000] "GET /1-ws HTTP/2.0" 101
backend:10.197.93.8:80 ssl:TLSv1.3/TLS_AES_256_GCM_SHA384 0 "-"
"curl/7.61.1" "-"
2021/07/21 13:37:04 [debug] 8#8: timer delta: 15332
2021/07/21 13:37:04 [debug] 8#8: worker cycle
2021/07/21 13:37:04 [debug] 8#8: epoll timer: -1"

2. It didn't work (The config is using the $http_upgrade variable which
seems to be empty)

"2021/07/21 13:39:40 [debug] 1#1: bind() 0.0.0.0:8060 #6
2021/07/21 13:39:40 [debug] 1#1: bind() 0.0.0.0:8063 #7
2021/07/21 13:39:40 [notice] 1#1: using the "epoll" event method
2021/07/21 13:39:40 [debug] 1#1: counter: 00007F6F213C3080, 1
2021/07/21 13:39:40 [notice] 1#1: nginx/1.18.0
2021/07/21 13:39:40 [notice] 1#1: OS: Linux 4.14.239-1626564138
2021/07/21 13:39:40 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2021/07/21 13:39:40 [debug] 1#1: write: 8, 00007FFEBDADD2C2, 2, 0
2021/07/21 13:39:40 [debug] 1#1: setproctitle: "nginx: master process
nginx-debug -c /usr/local/nginx/conf/nginx.conf -g daemon off;"
2021/07/21 13:39:40 [notice] 1#1: start worker processes
2021/07/21 13:39:40 [debug] 1#1: channel 3:8
2021/07/21 13:39:40 [notice] 1#1: start worker process 7
2021/07/21 13:39:40 [debug] 1#1: channel 9:10
2021/07/21 13:39:40 [debug] 7#7: add cleanup: 00007F6F213C8148
2021/07/21 13:39:40 [debug] 7#7: malloc: 00007F6F21455090:8
2021/07/21 13:39:40 [notice] 1#1: start worker process 8
2021/07/21 13:39:40 [debug] 1#1: pass channel s:1 pid:8 fd:9 to s:0 pid:7
fd:3
2021/07/21 13:39:40 [debug] 1#1: channel 11:12
2021/07/21 13:39:40 [debug] 8#8: add cleanup: 00007F6F213C8148
2021/07/21 13:39:40 [debug] 8#8: malloc: 00007F6F21455090:8
2021/07/21 13:39:40 [notice] 1#1: start worker process 9
2021/07/21 13:39:40 [debug] 1#1: pass channel s:2 pid:9 fd:11 to s:0 pid:7
fd:3
2021/07/21 13:39:40 [debug] 1#1: pass channel s:2 pid:9 fd:11 to s:1 pid:8
fd:9
2021/07/21 13:39:40 [debug] 1#1: channel 13:14
2021/07/21 13:39:40 [debug] 7#7: notify eventfd: 10
2021/07/21 13:39:40 [debug] 9#9: add cleanup: 00007F6F213C8148
2021/07/21 13:39:40 [debug] 7#7: eventfd: 11
2021/07/21 13:39:40 [debug] 9#9: malloc: 00007F6F21455090:8
2021/07/21 13:39:40 [notice] 1#1: start worker process 10
2021/07/21 13:39:40 [debug] 7#7: testing the EPOLLRDHUP flag: success
2021/07/21 13:39:40 [debug] 1#1: pass channel s:3 pid:10 fd:13 to s:0 pid:7
fd:3
2021/07/21 13:39:40 [debug] 8#8: notify eventfd: 12
2021/07/21 13:39:40 [debug] 1#1: pass channel s:3 pid:10 fd:13 to s:1 pid:8
fd:9
2021/07/21 13:39:40 [debug] 1#1: pass channel s:3 pid:10 fd:13 to s:2 pid:9
fd:11
2021/07/21 13:39:40 [debug] 7#7: malloc: 00007F6F21444450:6144
2021/07/21 13:39:40 [debug] 1#1: sigsuspend
2021/07/21 13:39:40 [debug] 8#8: eventfd: 13
2021/07/21 13:39:40 [debug] 7#7: malloc: 00007F6F20985460:237568
2021/07/21 13:39:40 [debug] 7#7: malloc: 00007F6F2096C470:98304
2021/07/21 13:39:40 [debug] 9#9: notify eventfd: 14
2021/07/21 13:39:40 [debug] 8#8: testing the EPOLLRDHUP flag: success
2021/07/21 13:39:40 [debug] 7#7: malloc: 00007F6F20953480:98304
2021/07/21 13:39:40 [debug] 9#9: eventfd: 15
2021/07/21 13:39:40 [debug] 8#8: malloc: 00007F6F21444450:6144
2021/07/21 13:39:40 [debug] 8#8: malloc: 00007F6F20985460:237568
2021/07/21 13:39:40 [debug] 8#8: malloc: 00007F6F2096C470:98304
2021/07/21 13:39:40 [debug] 9#9: testing the EPOLLRDHUP flag: success
2021/07/21 13:39:40 [debug] 9#9: malloc: 00007F6F21444450:6144
2021/07/21 13:39:40 [debug] 9#9: malloc: 00007F6F20985460:237568
2021/07/21 13:39:40 [debug] 9#9: malloc: 00007F6F2096C470:98304
2021/07/21 13:39:40 [debug] 8#8: malloc: 00007F6F20953480:98304
2021/07/21 13:39:40 [debug] 9#9: malloc: 00007F6F20953480:98304
2021/07/21 13:39:40 [debug] 7#7: epoll add event: fd:8 op:1 ev:00002001
2021/07/21 13:39:40 [debug] 7#7: setproctitle: "nginx: worker process"
2021/07/21 13:39:40 [debug] 7#7: worker cycle
2021/07/21 13:39:40 [debug] 7#7: epoll timer: -1
2021/07/21 13:39:40 [debug] 7#7: epoll: fd:8 ev:0001 d:00007F6F20985630
2021/07/21 13:39:40 [debug] 7#7: channel handler
2021/07/21 13:39:40 [debug] 7#7: channel: 32
2021/07/21 13:39:40 [debug] 7#7: channel command: 1
2021/07/21 13:39:40 [debug] 10#10: add cleanup: 00007F6F213C8148
2021/07/21 13:39:40 [debug] 7#7: get channel s:1 pid:8 fd:3
2021/07/21 13:39:40 [debug] 7#7: channel: 32
2021/07/21 13:39:40 [debug] 7#7: channel command: 1
2021/07/21 13:39:40 [debug] 10#10: malloc: 00007F6F21455090:8
2021/07/21 13:39:40 [debug] 7#7: get channel s:2 pid:9 fd:12
2021/07/21 13:39:40 [debug] 7#7: channel: 32
2021/07/21 13:39:40 [debug] 7#7: channel command: 1
2021/07/21 13:39:40 [debug] 7#7: get channel s:3 pid:10 fd:13
2021/07/21 13:39:40 [debug] 7#7: channel: -2
2021/07/21 13:39:40 [debug] 7#7: timer delta: 21
2021/07/21 13:39:40 [debug] 7#7: worker cycle
2021/07/21 13:39:40 [debug] 7#7: epoll timer: -1
2021/07/21 13:39:40 [debug] 9#9: epoll add event: fd:12 op:1 ev:00002001
2021/07/21 13:39:40 [debug] 8#8: epoll add event: fd:10 op:1 ev:00002001
2021/07/21 13:39:40 [debug] 9#9: setproctitle: "nginx: worker process"
2021/07/21 13:39:40 [debug] 8#8: setproctitle: "nginx: worker process"
2021/07/21 13:39:40 [debug] 9#9: worker cycle
2021/07/21 13:39:40 [debug] 8#8: worker cycle
2021/07/21 13:39:40 [debug] 9#9: epoll timer: -1
2021/07/21 13:39:40 [debug] 8#8: epoll timer: -1
2021/07/21 13:39:40 [debug] 9#9: epoll: fd:12 ev:0001 d:00007F6F20985630
2021/07/21 13:39:40 [debug] 8#8: epoll: fd:10 ev:0001 d:00007F6F20985630
2021/07/21 13:39:40 [debug] 9#9: channel handler
2021/07/21 13:39:40 [debug] 8#8: channel handler
2021/07/21 13:39:40 [debug] 10#10: notify eventfd: 16
2021/07/21 13:39:40 [debug] 9#9: channel: 32
2021/07/21 13:39:40 [debug] 8#8: channel: 32
2021/07/21 13:39:40 [debug] 9#9: channel command: 1
2021/07/21 13:39:40 [debug] 8#8: channel command: 1
2021/07/21 13:39:40 [debug] 9#9: get channel s:3 pid:10 fd:8
2021/07/21 13:39:40 [debug] 10#10: eventfd: 17
2021/07/21 13:39:40 [debug] 8#8: get channel s:2 pid:9 fd:8
2021/07/21 13:39:40 [debug] 9#9: channel: -2
2021/07/21 13:39:40 [debug] 8#8: channel: 32
2021/07/21 13:39:40 [debug] 9#9: timer delta: 21
2021/07/21 13:39:40 [debug] 8#8: channel command: 1
2021/07/21 13:39:40 [debug] 9#9: worker cycle
2021/07/21 13:39:40 [debug] 8#8: get channel s:3 pid:10 fd:9
2021/07/21 13:39:40 [debug] 9#9: epoll timer: -1
2021/07/21 13:39:40 [debug] 8#8: channel: -2
2021/07/21 13:39:40 [debug] 8#8: timer delta: 21
2021/07/21 13:39:40 [debug] 10#10: testing the EPOLLRDHUP flag: success
2021/07/21 13:39:40 [debug] 8#8: worker cycle
2021/07/21 13:39:40 [debug] 8#8: epoll timer: -1
2021/07/21 13:39:40 [debug] 10#10: malloc: 00007F6F21444450:6144
2021/07/21 13:39:40 [debug] 10#10: malloc: 00007F6F20985460:237568
2021/07/21 13:39:40 [debug] 10#10: malloc: 00007F6F2096C470:98304
2021/07/21 13:39:40 [debug] 10#10: malloc: 00007F6F20953480:98304
2021/07/21 13:39:40 [debug] 10#10: epoll add event: fd:14 op:1 ev:00002001
2021/07/21 13:39:40 [debug] 10#10: setproctitle: "nginx: worker process"
2021/07/21 13:39:40 [debug] 10#10: worker cycle
2021/07/21 13:39:40 [debug] 10#10: epoll timer: -1
2021/07/21 13:39:46 [debug] 7#7: epoll: fd:7 ev:0001 d:00007F6F20985548
2021/07/21 13:39:46 [debug] 7#7: timer delta: 5569
2021/07/21 13:39:46 [debug] 7#7: worker cycle
2021/07/21 13:39:46 [debug] 7#7: epoll timer: 60000
2021/07/21 13:39:46 [debug] 7#7: epoll: fd:14 ev:0001 d:00007F6F20985718
2021/07/21 13:39:46 [debug] 7#7: timer delta: 11
2021/07/21 13:39:46 [debug] 7#7: worker cycle
2021/07/21 13:39:46 [debug] 7#7: epoll timer: 59989
2021/07/21 13:39:46 [debug] 7#7: epoll: fd:14 ev:0001 d:00007F6F20985718
2021/07/21 13:39:46 [debug] 7#7: timer delta: 2
2021/07/21 13:39:46 [debug] 7#7: worker cycle
2021/07/21 13:39:46 [debug] 7#7: epoll timer: 59987
2021/07/21 13:39:46 [debug] 7#7: epoll: fd:14 ev:0001 d:00007F6F20985718
2021/07/21 13:39:46 [debug] 7#7: shmtx lock
2021/07/21 13:39:46 [debug] 7#7: slab alloc: 191 slot: 5
2021/07/21 13:39:46 [debug] 7#7: slab alloc: 00007F6F209D2000
2021/07/21 13:39:46 [debug] 7#7: slab alloc: 128 slot: 4
2021/07/21 13:39:46 [debug] 7#7: slab alloc: 00007F6F209D0080
2021/07/21 13:39:46 [debug] 7#7: shmtx unlock
2021/07/21 13:39:46 [debug] 7#7: shmtx lock
2021/07/21 13:39:46 [debug] 7#7: slab alloc: 191 slot: 5
2021/07/21 13:39:46 [debug] 7#7: slab alloc: 00007F6F209D2100
2021/07/21 13:39:46 [debug] 7#7: slab alloc: 128 slot: 4
2021/07/21 13:39:46 [debug] 7#7: slab alloc: 00007F6F209D0100
2021/07/21 13:39:46 [debug] 7#7: shmtx unlock
2021/07/21 13:39:46 [debug] 7#7: malloc: 00007F6F209045C0:262144
2021/07/21 13:39:46 [debug] 7#7: timer delta: 7
2021/07/21 13:39:46 [debug] 7#7: worker cycle
2021/07/21 13:39:46 [debug] 7#7: epoll timer: 120000
2021/07/21 13:39:46 [debug] 7#7: epoll: fd:15 ev:0004 d:00007F6F20985800
2021/07/21 13:39:46 [debug] 7#7: epoll: fd:14 ev:0001 d:00007F6F20985718
2021/07/21 13:39:46 [debug] 7#7: timer delta: 2
2021/07/21 13:39:46 [debug] 7#7: worker cycle
2021/07/21 13:39:46 [debug] 7#7: epoll timer: 120000
2021/07/21 13:39:46 [debug] 7#7: epoll: fd:15 ev:0005 d:00007F6F20985800
10.197.96.163 - - [21/Jul/2021:13:39:46 +0000] "GET /1-ws HTTP/2.0" 502
backend:10.197.93.8:80 ssl:TLSv1.3/TLS_AES_256_GCM_SHA384 150 "-"
"curl/7.61.1" "-"
2021/07/21 13:39:46 [debug] 7#7: timer delta: 4
2021/07/21 13:39:46 [debug] 7#7: posted event 00007F6F2096C590
2021/07/21 13:39:46 [debug] 7#7: worker cycle
2021/07/21 13:39:46 [debug] 7#7: epoll timer: 180000
2021/07/21 13:39:46 [debug] 7#7: epoll: fd:14 ev:0001 d:00007F6F20985718
2021/07/21 13:39:46 [debug] 7#7: timer delta: 1
2021/07/21 13:39:46 [debug] 7#7: worker cycle
2021/07/21 13:39:46 [debug] 7#7: epoll timer: -1"


I have also test case 3, where the $http_upgrade variable is still used in
the configuration. Here though, I have used a server { listen 80 } context
for the nginx which connects to the upstreams, without doing a redirect to
https. This case also worked, $http_upgrade seems to be recognized in this
context:

"2021/07/21 13:41:42 [debug] 1#1: bind() 0.0.0.0:8060 #6
2021/07/21 13:41:42 [debug] 1#1: bind() 0.0.0.0:8063 #7
2021/07/21 13:41:42 [notice] 1#1: using the "epoll" event method
2021/07/21 13:41:42 [debug] 1#1: counter: 00007FE63A134080, 1
2021/07/21 13:41:42 [notice] 1#1: nginx/1.18.0
2021/07/21 13:41:42 [notice] 1#1: OS: Linux 4.14.239-1626564138
2021/07/21 13:41:42 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2021/07/21 13:41:42 [debug] 1#1: write: 8, 00007FFCC83BBFC2, 2, 0
2021/07/21 13:41:42 [debug] 1#1: setproctitle: "nginx: master process
nginx-debug -c /usr/local/nginx/conf/nginx.conf -g daemon off;"
2021/07/21 13:41:42 [notice] 1#1: start worker processes
2021/07/21 13:41:42 [debug] 1#1: channel 3:8
2021/07/21 13:41:42 [notice] 1#1: start worker process 8
2021/07/21 13:41:42 [debug] 1#1: channel 9:10
2021/07/21 13:41:42 [debug] 8#8: add cleanup: 00007FE63A1440A8
2021/07/21 13:41:42 [debug] 8#8: malloc: 00007FE63A1C6090:8
2021/07/21 13:41:42 [notice] 1#1: start worker process 9
2021/07/21 13:41:42 [debug] 1#1: pass channel s:1 pid:9 fd:9 to s:0 pid:8
fd:3
2021/07/21 13:41:42 [debug] 1#1: channel 11:12
2021/07/21 13:41:42 [debug] 9#9: add cleanup: 00007FE63A1440A8
2021/07/21 13:41:42 [debug] 9#9: malloc: 00007FE63A1C6090:8
2021/07/21 13:41:42 [notice] 1#1: start worker process 10
2021/07/21 13:41:42 [debug] 1#1: pass channel s:2 pid:10 fd:11 to s:0 pid:8
fd:3
2021/07/21 13:41:42 [debug] 8#8: notify eventfd: 10
2021/07/21 13:41:42 [debug] 8#8: eventfd: 11
2021/07/21 13:41:42 [debug] 1#1: pass channel s:2 pid:10 fd:11 to s:1 pid:9
fd:9
2021/07/21 13:41:42 [debug] 1#1: channel 13:14
2021/07/21 13:41:42 [debug] 10#10: add cleanup: 00007FE63A1440A8
2021/07/21 13:41:42 [debug] 10#10: malloc: 00007FE63A1C6090:8
2021/07/21 13:41:42 [debug] 9#9: notify eventfd: 12
2021/07/21 13:41:42 [debug] 8#8: testing the EPOLLRDHUP flag: success
2021/07/21 13:41:42 [debug] 9#9: eventfd: 13
2021/07/21 13:41:42 [debug] 8#8: malloc: 00007FE63A1B5460:6144
2021/07/21 13:41:42 [notice] 1#1: start worker process 11
2021/07/21 13:41:42 [debug] 8#8: malloc: 00007FE6396F6470:237568
2021/07/21 13:41:42 [debug] 1#1: pass channel s:3 pid:11 fd:13 to s:0 pid:8
fd:3
2021/07/21 13:41:42 [debug] 9#9: testing the EPOLLRDHUP flag: success
2021/07/21 13:41:42 [debug] 8#8: malloc: 00007FE6396DD480:98304
2021/07/21 13:41:42 [debug] 1#1: pass channel s:3 pid:11 fd:13 to s:1 pid:9
fd:9
2021/07/21 13:41:42 [debug] 1#1: pass channel s:3 pid:11 fd:13 to s:2
pid:10 fd:11
2021/07/21 13:41:42 [debug] 9#9: malloc: 00007FE63A1B5460:6144
2021/07/21 13:41:42 [debug] 1#1: sigsuspend
2021/07/21 13:41:42 [debug] 9#9: malloc: 00007FE6396F6470:237568
2021/07/21 13:41:42 [debug] 9#9: malloc: 00007FE6396DD480:98304
2021/07/21 13:41:42 [debug] 8#8: malloc: 00007FE6396C4490:98304
2021/07/21 13:41:42 [debug] 10#10: notify eventfd: 14
2021/07/21 13:41:42 [debug] 10#10: eventfd: 15
2021/07/21 13:41:42 [debug] 11#11: add cleanup: 00007FE63A1440A8
2021/07/21 13:41:42 [debug] 9#9: malloc: 00007FE6396C4490:98304
2021/07/21 13:41:42 [debug] 11#11: malloc: 00007FE63A1C6090:8
2021/07/21 13:41:42 [debug] 10#10: testing the EPOLLRDHUP flag: success
2021/07/21 13:41:42 [debug] 10#10: malloc: 00007FE63A1B5460:6144
2021/07/21 13:41:42 [debug] 10#10: malloc: 00007FE6396F6470:237568
2021/07/21 13:41:42 [debug] 10#10: malloc: 00007FE6396DD480:98304
2021/07/21 13:41:42 [debug] 11#11: notify eventfd: 16
2021/07/21 13:41:42 [debug] 10#10: malloc: 00007FE6396C4490:98304
2021/07/21 13:41:42 [debug] 11#11: eventfd: 17
2021/07/21 13:41:42 [debug] 8#8: epoll add event: fd:8 op:1 ev:00002001
2021/07/21 13:41:42 [debug] 8#8: setproctitle: "nginx: worker process"
2021/07/21 13:41:42 [debug] 9#9: epoll add event: fd:10 op:1 ev:00002001
2021/07/21 13:41:42 [debug] 8#8: worker cycle
2021/07/21 13:41:42 [debug] 8#8: epoll timer: -1
2021/07/21 13:41:42 [debug] 11#11: testing the EPOLLRDHUP flag: success
2021/07/21 13:41:42 [debug] 9#9: setproctitle: "nginx: worker process"
2021/07/21 13:41:42 [debug] 9#9: worker cycle
2021/07/21 13:41:42 [debug] 9#9: epoll timer: -1
2021/07/21 13:41:42 [debug] 11#11: malloc: 00007FE63A1B5460:6144
2021/07/21 13:41:42 [debug] 8#8: epoll: fd:8 ev:0001 d:00007FE6396F6640
2021/07/21 13:41:42 [debug] 8#8: channel handler
2021/07/21 13:41:42 [debug] 9#9: epoll: fd:10 ev:0001 d:00007FE6396F6640
2021/07/21 13:41:42 [debug] 11#11: malloc: 00007FE6396F6470:237568
2021/07/21 13:41:42 [debug] 8#8: channel: 32
2021/07/21 13:41:42 [debug] 9#9: channel handler
2021/07/21 13:41:42 [debug] 8#8: channel command: 1
2021/07/21 13:41:42 [debug] 11#11: malloc: 00007FE6396DD480:98304
2021/07/21 13:41:42 [debug] 8#8: get channel s:1 pid:9 fd:3
2021/07/21 13:41:42 [debug] 9#9: channel: 32
2021/07/21 13:41:42 [debug] 9#9: channel command: 1
2021/07/21 13:41:42 [debug] 8#8: channel: 32
2021/07/21 13:41:42 [debug] 9#9: get channel s:2 pid:10 fd:8
2021/07/21 13:41:42 [debug] 8#8: channel command: 1
2021/07/21 13:41:42 [debug] 8#8: get channel s:2 pid:10 fd:12
2021/07/21 13:41:42 [debug] 9#9: channel: 32
2021/07/21 13:41:42 [debug] 9#9: channel command: 1
2021/07/21 13:41:42 [debug] 8#8: channel: 32
2021/07/21 13:41:42 [debug] 9#9: get channel s:3 pid:11 fd:9
2021/07/21 13:41:42 [debug] 8#8: channel command: 1
2021/07/21 13:41:42 [debug] 9#9: channel: -2
2021/07/21 13:41:42 [debug] 8#8: get channel s:3 pid:11 fd:13
2021/07/21 13:41:42 [debug] 9#9: timer delta: 21
2021/07/21 13:41:42 [debug] 9#9: worker cycle
2021/07/21 13:41:42 [debug] 8#8: channel: -2
2021/07/21 13:41:42 [debug] 11#11: malloc: 00007FE6396C4490:98304
2021/07/21 13:41:42 [debug] 9#9: epoll timer: -1
2021/07/21 13:41:42 [debug] 8#8: timer delta: 21
2021/07/21 13:41:42 [debug] 8#8: worker cycle
2021/07/21 13:41:42 [debug] 8#8: epoll timer: -1
2021/07/21 13:41:42 [debug] 10#10: epoll add event: fd:12 op:1 ev:00002001
2021/07/21 13:41:42 [debug] 10#10: setproctitle: "nginx: worker process"
2021/07/21 13:41:42 [debug] 10#10: worker cycle
2021/07/21 13:41:42 [debug] 10#10: epoll timer: -1
2021/07/21 13:41:42 [debug] 10#10: epoll: fd:12 ev:0001 d:00007FE6396F6640
2021/07/21 13:41:42 [debug] 10#10: channel handler
2021/07/21 13:41:42 [debug] 10#10: channel: 32
2021/07/21 13:41:42 [debug] 10#10: channel command: 1
2021/07/21 13:41:42 [debug] 10#10: get channel s:3 pid:11 fd:8
2021/07/21 13:41:42 [debug] 10#10: channel: -2
2021/07/21 13:41:42 [debug] 10#10: timer delta: 21
2021/07/21 13:41:42 [debug] 10#10: worker cycle
2021/07/21 13:41:42 [debug] 10#10: epoll timer: -1
2021/07/21 13:41:42 [debug] 11#11: epoll add event: fd:14 op:1 ev:00002001
2021/07/21 13:41:42 [debug] 11#11: setproctitle: "nginx: worker process"
2021/07/21 13:41:42 [debug] 11#11: worker cycle
2021/07/21 13:41:42 [debug] 11#11: epoll timer: -1
2021/07/21 13:41:48 [debug] 8#8: epoll: fd:6 ev:0001 d:00007FE6396F6470
2021/07/21 13:41:48 [debug] 8#8: timer delta: 6547
2021/07/21 13:41:48 [debug] 8#8: worker cycle
2021/07/21 13:41:48 [debug] 8#8: epoll timer: 60000
2021/07/21 13:41:48 [debug] 8#8: epoll: fd:14 ev:0001 d:00007FE6396F6728
2021/07/21 13:41:48 [debug] 8#8: timer delta: 0
2021/07/21 13:41:48 [debug] 8#8: worker cycle
2021/07/21 13:41:48 [debug] 8#8: epoll timer: 120000
2021/07/21 13:41:48 [debug] 8#8: epoll: fd:14 ev:0004 d:00007FE6396F6728
2021/07/21 13:41:48 [debug] 8#8: timer delta: 0
2021/07/21 13:41:48 [debug] 8#8: worker cycle
2021/07/21 13:41:48 [debug] 8#8: epoll timer: 120000
2021/07/21 13:41:48 [debug] 8#8: epoll: fd:15 ev:0004 d:00007FE6396F6810
2021/07/21 13:41:48 [debug] 8#8: timer delta: 1
2021/07/21 13:41:48 [debug] 8#8: worker cycle
2021/07/21 13:41:48 [debug] 8#8: epoll timer: 120000
2021/07/21 13:41:48 [debug] 8#8: epoll: fd:15 ev:0005 d:00007FE6396F6810
2021/07/21 13:41:48 [debug] 8#8: timer delta: 1
2021/07/21 13:41:48 [debug] 8#8: worker cycle
2021/07/21 13:41:48 [debug] 8#8: epoll timer: 119999
2021/07/21 13:41:48 [debug] 8#8: epoll: fd:15 ev:0005 d:00007FE6396F6810
2021/07/21 13:41:48 [debug] 8#8: timer delta: 0
2021/07/21 13:41:48 [debug] 8#8: worker cycle
2021/07/21 13:41:48 [debug] 8#8: epoll timer: 119999
2021/07/21 13:41:51 [debug] 8#8: epoll: fd:14 ev:2005 d:00007FE6396F6728
10.197.96.163 - - [21/Jul/2021:13:41:51 +0000] "GET /1-ws HTTP/1.1" 101
backend:10.197.93.8:80 ssl:-/- 12 "-" "curl/7.61.1" "-"
2021/07/21 13:41:51 [debug] 8#8: timer delta: 2870
2021/07/21 13:41:51 [debug] 8#8: worker cycle
2021/07/21 13:41:51 [debug] 8#8: epoll timer: -1"


Judging by the fact that this 3rd test case worked, it seems that the
$http_upgrade is there when not doing the ssl termination on the nginx
reverse proxy. I don't know though about nginx internals, why this is.

Best,
Dorin

Am Mi., 21. Juli 2021 um 12:48 Uhr schrieb Sergey A. Osokin <
osa@freebsd.org.ru>:

> 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
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Embedded variables from ngx_http_core_module and websocket connections

Dorin RuV July 20, 2021 06:42AM

Re: Embedded variables from ngx_http_core_module and websocket connections

Sergey A. Osokin July 21, 2021 06:50AM

Re: Embedded variables from ngx_http_core_module and websocket connections

Dorin RuV July 21, 2021 09:48AM

Re: Embedded variables from ngx_http_core_module and websocket connections

Francis Daly July 21, 2021 05:42PM

Re: Embedded variables from ngx_http_core_module and websocket connections

Dorin RuV July 22, 2021 03:56AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 61
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready