Proxy Caching ignore path

jvanetten nginx-forum at
Tue Aug 6 14:27:57 UTC 2019

I have a situation where I need to enable proxy cache for a gateway but
anything that goes to /gateway/public/files/ I do not want to cache. I have
tried nested locations and all kinds of configurations with no success. It
usually lands up with 404 errors on /gateway/public/files/ the complete url
includes a file reference like so /gateway/public/files/kd774831ldja3

caching is working for anything going to /gateway/

location /gateway/ {
    	proxy_cache     	gateway_cache;
	proxy_cache_valid 	200 302 10m;
        proxy_redirect           off;
        proxy_set_header         X-Real-IP $remote_addr;
        proxy_set_header         X-Forwarded-For
        proxy_set_header         Host $http_host;
        proxy_hide_header        Access-Control-Allow-Origin;
        add_header 'Access-Control-Allow-Origin' '*' always;
        rewrite ^/gateway/(.*) /$1 break;
        proxy_pass $elb;

Posted at Nginx Forum:,285128,285128#msg-285128

More information about the nginx mailing list