nginx根据cookie分发

来源:互联网 发布:数组slice方法 编辑:程序博客网 时间:2024/05/17 00:07
        location / {

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


set $target 'unknown';
if ( $http_cookie ~* "target=(.*)$")
{
set $target $1;
}


if ($domain ~ "target1")
{
proxy_pass http://target1;
break;
}

if ($domain ~ "target2")
{
proxy_pass http://target2;
break;
}

proxy_pass http://dfeualt;

        }
原创粉丝点击