现在有端口9006 负载均衡了二台虚拟机的二个端口:9006和9016二个端口共四个负载,任何一个有问题都不会影响系统访问,现在有二个域名和一个IP都要指向这个站点,Nginx中的配置如下:
nginx.conf配置如下
#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; client_max_body_size 50m; 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; upstream webBO9006{ #ip_hash;默认将按IP自动轮询方式 server 192.168.8.1:9006; server 192.168.8.1:9016;#不同端口 server 192.168.8.2:9006;#不同IP server 192.168.8.2:9016; } server { listen 9006; server_name a.qq.com b.qq.com 122.122.122.122; location / { proxy_pass http://webBO9006;#一定要和upstream后面名字一样 proxy_hide_header Set-Cookie; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }