I am new to NGINX and need to know how to do this in a special location (folder)
- remove all query parameters
- proxy request to another server
- cache the result locally for x minutes
Config snippet:
location /cache {
rewrite /cache/([^/\?]) /cache/$1 break;
proxy_pass http://foo.bar/original/;
expire 5m;
}
I already saw different ideas with overwriting $args
and using ?
for arguments removal. But I could not get anything to work like expected.
E.g.
1. Request
---
Request: http://foo.bar/cache/text.css?abc=123
Rewrite: http://foo.bar/cache/text.css
Cache miss
Proxy: http://fuzzu.buzzi/original/text.css
(store in local cache)
Expire: http://foo.bar/cache/text.css (after 5min)
2. Request
---
Request: http://foo.bar/cache/text.css?abc=123
Rewrite: http://foo.bar/cache/text.css
Cache hit
test.css
totext.css
?