脚本宝典收集整理的这篇文章主要介绍了php – Nginx不会将Cookie传递给代理,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
server { listen 80; server_name www.example.com; location / { root /data/sITes/www.example.com/widgets/public_htML; index index.PHP index.html index.htm; try_files $uri $uri/ /index.PHP?rt=$uri&$args; } location ~ .PHP${ root /data/sites/www.example.com/site/public_html; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_SCRIPT_NAME; fastcgi_param REQUEST_URI $uri; fastcgi_index index.PHP; include fastcgi_params; fastcgi_param env staging; } location /api { PRoxy_pass_header Set-Cookie; proxy_cookie_domain $host example.com; proxy_pass_header P3P; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Fowarded-Host $host; proxy_pass http://api.example.com/; proxy_connect_timeout 1; } }
但是当我检查ajax调用时,它看起来像这样:
上面的图片显示正在发送的cookie应该是.example.com时具有N / A域.它适用于我的apache / PHP配置,但不适用于我的Nginx / PHP配置.我究竟做错了什么?
server_name www.example.com;
有:
server_name www.example.com example.com *.example.com;
以上是脚本宝典为你收集整理的php – Nginx不会将Cookie传递给代理全部内容,希望文章能够帮你解决php – Nginx不会将Cookie传递给代理所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。