问题
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?
回答1:
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;
来源:https://stackoverflow.com/questions/19874781/nginx-reverse-proxy-for-socket-io-dropping-messages-at-a-certain-size