背景: IM 即時通信時候 , 前期我用的是IP 沒什麼問題,固然上線確定要搞個域名搞搞了! nginx
那麼問題來了------》Nginx 我按照原先那樣配置時候不行了,app
鏈接不了。負載均衡
解決方法:tcp
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; gzip on; map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80; server_name manage.tbnb1.cn; #charset koi8-r; #access_log logs/host.access.log main; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; location / { proxy_pass http://127.0.0.1:8081; proxy_connect_timeout 600; proxy_read_timeout 600; } } server { listen 80; server_name sso.tbnb1.cn; #charset koi8-r; #access_log logs/host.access.log main; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; location / { proxy_pass http://127.0.0.1:8099; proxy_connect_timeout 600; proxy_read_timeout 600; } } server { listen 80; server_name q.tbnb1.cn; #charset koi8-r; #access_log logs/host.access.log main; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; location / { proxy_pass http://127.0.0.1:8089; proxy_connect_timeout 600; proxy_read_timeout 600; } } server { listen 80; server_name message.tbnb1.cn; #charset koi8-r; #access_log logs/host.access.log main; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; location / { proxy_pass http://127.0.0.1:8083; proxy_connect_timeout 600; proxy_read_timeout 600; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } } }
重要位置須要配置的spa
map $http_upgrade $connection_upgrade {
default upgrade; '' close; }3d
proxy_http_version 1.1;代理
proxy_set_header Upgrade $http_upgrade; code
proxy_set_header Connection "upgrade";orm
完美解決問題了! 什麼東西都要本身去動手 ,你才能發現問題解決問題! 天天用嘴說反向代理 ,負載均衡! 而後都他媽的空談!server