要实现的效果是这样的:浏览器打开http://localhost:8088/library(代理访问Web2服务器),登录进后台,产生一个session;打开另一个网页http://localhost:8088/index.html(Nginx服务器),在这个页面中发出ajax请求checkBook访问Web2服务器但是提示要登录,怎么样才能共享刚才的session?nginx配置如下:
server
{
listen 8088;
server_name localhost;
location /
{
root html;
index index.html index.htm;
proxy_cookie_path / /library;
proxy_set_header Cookie $http_cookie;
}
location /library #第一次有效,注册服务前配置好
{
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X- Requested-With,If-Modified-Since,Cache-Control,Content-Type';
proxy_set_header Host "10.10.2.86:8090";
proxy_pass http://10.10.2.86:8090/library;
}
}
其中Web2服务器不受控制,哪位大神指点下,非常感谢!