Reverse proxy'ing of events not working

Leonard Theivendra theivend at
Mon Jun 3 18:55:52 UTC 2019

Hi, I've been trying to get nginx reverse proxy'ing of events
working but not having any luck so would greatly appreciate any
help/insight. Basically my scenario is: nginx running in a docker container
(based on the nginx:stable-alpine image), a node server app serving up rest
APIs as well as responses via when those APIs are called. On the
client side, the aim is to call these APIs via the proxy, and also listen
to events return back through the proxy. And this is all ssl

My nginx conf file:

worker_processes  1;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/;

events {
    worker_connections 1024;

http {
    include /etc/nginx/mime.types;
    default_type  application/octet-stream;
    access_log  /var/log/nginx/access.log  main;
    sendfile on;
    keepalive_timeout  65;

    server {
        listen 8080 ssl;

        server_name localhost;

        ssl_certificate /etc/nginx/conf.d/cert.pem;
        ssl_certificate_key /etc/nginx/conf.d/key.pem;

        location / {
            proxy_pass https://apiandsocketservername:9091;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";

My simple client node app:

socket = require('')(`https://localhost:8080`, {timeout:
5000, rejectUnauthorized: false});
// Connect to the socket
socket.on('connect', () => {
    console.log('Connected to server');
// Wait on event named 'projectValidated'
socket.on('projectValidated', (args) => {

So the scenario would be to start up the node app above, then hit the rest
API endpoint on https://localhost:8080 via curl, and listen for the socket
event on https://localhost:8080 originating from
https://apiandsocketservername:9091 via the proxy.

When I run the nginx container and client locally on my laptop
everything works, and the nginx container logs has this added line when the node app client connects, and no extra logging when the
events are successfully received: - - [31/May/2019:16:31:07 +0000]
"GET /
 HTTP/1.1" 200 3 "-" "nodeXMLHttpRequest" "-"
When I kill the client, nginx emits this single line in the log: - - [31/May/2019:16:34:18 +0000]
"GET /
HTTP/1.1" 101 379 "-" "-" "-"

But when I run the same scenario on a kubernetes cluster where the nginx
proxy container and the client is on one pod and the rest api and server is on a different pod: all the rest api proxy'ing works
for the both the https api calls and responses, and also the node app is
able to do the socket connection properly, but the event is never
received successfully. Nginx also continuously emits these two lines in the
log every 25 seconds: - - [31/May/2019:17:37:26 +0000]
"GET /
 HTTP/1.1" 200 3 "-" "node-XMLHttpRequest" "-" - - [31/May/2019:17:37:26 +0000]
 HTTP/1.1" 200 2 "-" "node-XMLHttpRequest" "-"

Would anyone be able to shed light on what could be going wrong and if I
need to change anything in my nginx conf file? And what the above two lines
repeatedly emitted in the nginx log mean?

Thanks in advance,

Len Theivendra
IBM Canada Software Lab
email: theivend at
tel: (905) 413-3777  tie: 969-3777
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list