Welcome! Log In Create A New Profile

Advanced

nginx proxy_pass and proxy_cache

Michiel Beijen
November 10, 2021 10:30AM
Hi there,

I use nginx as caching reverse proxy.

I have requests coming as /something/data1/request123.xml
I have other requests coming in as /something/data1/bigfile424.bin

I want to forward all requests to an origin on /data1/

Currently I use a location block:

location /something/ {
proxy_cache disk_cache;
proxy_pass http://origin/data1/;
}

This works great! Except the disk is rather slow and while the bin files
are mostly static and can be cached pretty good, the xml files, which
receive an awful lot of requests, update rather quickly. I prefer to cache
them on a FAST disk cache (or rather on a tmpfs partition). So now I would
try;

location /something/ {
proxy_cache disk_cache;
proxy_pass http://origin/data1/;
location ~* \.xml$ {
proxy_cache fast_disk_cache;
proxy_pass http://origin/data1;
}
}

As we know, proxy_pass does not inherit so I have to specify it also in the
nested location. But I can't use proxy_pass like this with a URI in a
location block containing a regex. And I can't make a location block for a
mimetype, or using another specifier than regexes to filter out requests to
certain 'file types'. Is there any other 'good' solution except for, on my
origin adding rewrites from /something/data1/ to /data1/?

--
Michiel
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

nginx proxy_pass and proxy_cache

Michiel Beijen November 10, 2021 10:30AM

RE: nginx proxy_pass and proxy_cache

Reinis Rozitis November 10, 2021 02:00PM

Re: nginx proxy_pass and proxy_cache

Francis Daly November 11, 2021 03:56AM

Re: nginx proxy_pass and proxy_cache

Francis Daly November 11, 2021 04:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 64
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready