I'm using an Nginx server to host an PHP web application, and tried to upgrade its security by using some security headers, I've tested it on a staging environment and it works fine, so I've decided to use the same config on Production, and after a week we had some trouble with many users reporting things like sessions getting closed when doing any request on the app.
So I've checked the logs, other configs and nothing worked. Then, I've removed the add_header Set-Cookie "Path=/; HttpOnly; Secure"
and the application started working again.
Below are the current configuration on Staging, and except for the above directive, it's the same thing on Production
#Secure flag for Cookies
add_header Set-Cookie "Path=/; HttpOnly; Secure";
#XSS Protection
add_header X-XSS-Protection "1; mode=block";
#Clickjacking Protection
add_header X-Frame-Options "SAMEORIGIN";
#Check MIME type for files
add_header X-Content-Type-Options nosniff;
Any clues on why do nginx is closing user sessions when I use it?