首页 > 其他 > 详细

nginx upstream作为变量

时间:2015-08-18 11:44:21      阅读:329      评论:0      收藏:0      [点我收藏+]

 

 

upstream wdzjbbs_varnish{
session_sticky;
server 10.174.35.11 weight=1 max_fails=2 fail_timeout=30s;
}

upstream wdzjbbs{
session_sticky;
server 10.174.39.137 weight=1 max_fails=2 fail_timeout=30s;
}

server {

...

set $upstream_x "wdzjbbs_varnish";
if ( $http_cookie ~* "auth_token"){
  set $upstream_x  "wdzjbbs";
  }
if ( $request_uri ~* "search"){
  set $upstream_x "wdzjbbs";

  }

...

location / {
proxy_pass http://$upstream_x;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

 

注意:通过以上对upsteram变量进行判断设置,这样做,可以通过cookie来判断有无后跳转到后台哪台服务器上

nginx upstream作为变量

原文:http://www.cnblogs.com/zenghui940/p/4738882.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!