1 # websocket 2 map $http_upgrade $connection_upgrade { 3 default upgrade; 4 '' close; 5 } 6 7 # 负载均衡配置 8 upstream websocket { 9 server 127.0.0.1:8090; 10 server 127.0.0.1:8091; 11 server 127.0.0.1:8092; 12 } 13 14 server { 15 listen 80; 16 location / { 17 client_max_body_size 100m; 18 root html; 19 index index.html index.htm; 20 proxy_pass http://tomcat_server; 21 proxy_set_header Host $http_host; 22 proxy_connect_timeout 18000; 23 proxy_send_timeout 18000; 24 proxy_read_timeout 18000; 25 proxy_ignore_client_abort on; 26 proxy_set_header X-Real-IP $remote_addr; 27 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 28 proxy_set_header X-Forwarded-Host $server_name; 29 # websocket 支持 30 proxy_http_version 1.1; 31 proxy_set_header Upgrade $http_upgrade; 32 proxy_set_header Connection $connection_upgrade; 33 } 34 }
客户端建立连接数量配置
1 events { 2 worker_connections 40960; 3 multi_accept on; 4 use epoll; 5 } 6 7 sendfile on; 8 tcp_nopush on; 9 tcp_nodelay on; 10 keepalive_timeout 65; 11 types_hash_max_size 2048; 12 13 client_header_timeout 120s; #调大点 14 client_body_timeout 120s; #调大点 15 client_max_body_size 100m; #主要是这个参数,限制了上传文件大大小 16 client_body_buffer_size 256k;