I have a cookie set will work for all subdomains, .example.com . I have nginx ajax calls go through a proxy_pass but the cookie does not remain. My configuration looks like this:
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;
}
}
But when I check the ajax call, it looks like this:
The picture above shows the cookie being sent has a domain of N/A when it should be .example.com . It works with my Apache/PHP configuration but does not with my nginx/php configuration. What am I doing wrong?
location / {
proxy_pass http://localhost:8000;
proxy_set_header Host $host; # MAGIC
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With