I have nginx set up as a reverse proxy server and I want to remove certain cookies set on the backed server (apache)
My website uses a lot of cookies which I can not control (Expression Engine CMS, don't ask me why). I want to delete some of those cookies (lets say cookies A B and C) and keep some other (cookies D and E).
After that I will set up nginx to respond with cached content only if the request has no cookies.
Do you have any idea how to do this? Thanks
So far I have in my config:
proxy_cache_path /opt/nginx/cache levels=1:2 keys_zone=mycache:20m max_size=1G;
proxy_temp_path /opt/nginx/tmp_cache/;
proxy_ignore_headers Expires Cache-Control Set-Cookie;
proxy_cache_use_stale error timeout invalid_header http_502;
proxy_cache_bypass $cookie_nocache;
proxy_no_cache $cookie_nocache;
...
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache mycache;
proxy_cache_valid 200 302 6h;
proxy_cache_valid 404 1m;
proxy_pass http://x.x.x.x:8080;
}
/var/cache/nginx – the path to the local disk directory for the cache. levels – defines the hierarchy levels of a cache, it sets up a two-level directory hierarchy under /var/cache/nginx.
proxy_connect_timeout 60s; Context: http , server , location. Defines a timeout for establishing a connection with a proxied server. It should be noted that this timeout cannot usually exceed 75 seconds.
Although you already mentioned that you switched to Varnish to accomplish what you asked for, the correct answer would have been to use the headers-more-nginx-module
which basically allows you the same as the Varnish function does (and much more).
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