您的位置:首页 > 运维架构 > Nginx

nginx 配置

2015-11-12 16:50 567 查看
upstream mash {
ip_hash;
server 127.0.0.1:8081;
server 192.168.0.11:8081;
}

server {

location / {
if ($request_method = POST ) {
proxy_next_upstream error;
}

if ($request_method = PUT ) {
proxy_next_upstream error;
}

proxy_pass http://mash/; 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_next_upstream,这个配置指定了 nginx在从一个后端主机取数据遇到何种错误时会转到下一个后端主机,里头写上的就是会出现502的所有情况拉,默认是error timeout。error就是当机、断线之类的,timeout就是读取堵塞超时,比较容易理解

全部值包括:

proxy_next_upstream error | timeout | invalid_header | http_500 | http_502 | http_503 | http_504 | http_403 |
http_404 | off ...;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: