读写分离

upstream hbwx_read {
#ip_hash;
server 192.168.7.53:18080 weight=2 max_fails=5 fail_timeout=2;
}

upstream hbwx_write {
#ip_hash;
server 192.168.6.203:11000 weight=2 max_fails=10 fail_timeout=2;
#server 127.0.0.1:8080 backup;
}

server {
listen 80;
server_name localhost;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root html;
index index.html index.htm;
}


location ~ ^/1[0-9][0-9]/ {
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://hbwx_read;
}

location ~ ^/hbwx/wsdc/(addOrderCart|paySaleOrder|addSaleOrder).do$ {
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://hbwx_write;
}

location ~ ^/hbwx/ {
#echo "match hbwexin first";
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://hbwx_read;
}


error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}