简体   繁体   中英

Nginx reverse proxy for Socket.IO dropping messages at a certain size

I have nginx setup as a reverse proxy with the following config.

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include  mime.types;

    default_type  application/octet-stream;
    keepalive_timeout  65;

    map $http_upgrade $connection_upgrade {
        default  upgrade;
        ''  close;
    }

    server {
        listen  8080;

        server_name  localhost;

        add_header  X-Cache-Status  $upstream_cache_status;

        location /node/ {
            proxy_http_version  1.1;
            proxy_pass   http://127.0.0.1:8000/;
            proxy_redirect  off;
            proxy_set_header  Connection  $connection_upgrade;
            proxy_set_header  Upgrade  $http_upgrade;
        }
    }
}

I'm connecting to it with the following code.

socket = io.connect('http://localhost:8080', {
    'resource': 'node/socket.io'
});

Once connected, everything works normally, except that messages above around 15kb are never received by Node. Nginx doesn't log anything to the access or error logs.

I'm pretty sure it's an nginx configuration issue, but I haven't found any settings that affect this behavior. I've tried client_body_buffer_size size , proxy_buffers , proxy_buffer_size , tcp_nodelay , and large_client_header_buffers .

How can I get nginx to stop dropping these messages?

I guess the problem did have to do with the proxy buffers, I just hadn't set them high enough. The following is working now for messages around 5mb.

proxy_buffers 8 2m;
proxy_buffer_size 10m;
proxy_busy_buffers_size 10m;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM