nginx负载均衡应用
nginx的官方:负载均衡示例:http://wiki.nginx.org/NginxChsLoadBalanceExample
?
我们项目中的应用 代码片段:
?
?
# You may add here your# server {#...# }# statements for each of your virtual hostsupstream ahmymyty {ip_hash;server 192.168.0.31:8085;server 192.168.0.150:8085;server 192.168.0.151:8085;server 192.168.0.152:8085;}server {listen 80;server_name www.ahmymyty.com ahmymyty.com;access_log /var/log/nginx/ahmymyty.log;location /nginx-status {stub_status on;#access_log /var/log/nginx/nginx_status_mmt.log;access_log off;allow 192.168.0.10;allow 192.168.0.25;allow 192.168.0.31;allow 220.178.14.98;deny all;#auth_basic "NginxStatus";}location /resin-status {proxy_redirect off;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_pass http://ahmymyty;allow 127.0.0.1;allow 220.178.14.98;allow 192.168.0.0/24;deny all; } location / {proxy_redirect off;proxy_set_header Host $host;proxy_pass http://ahmymyty;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_redirect false;proxy_connect_timeout 300;proxy_send_timeout 300;proxy_read_timeout 300;}location ~ .*VerificationCode.*\.jpg$ {proxy_redirect off;proxy_set_header Host $host;proxy_pass http://ahmymyty;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;#proxy_redirect false;access_log off;}location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico|js|css|txt|zip)$ {proxy_redirect off;proxy_set_header Host $host;proxy_pass http://ahmymyty;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_redirect false;access_log off;expires 7d;}}?
?
?