I want to cache all *.html
files in a Nginx reverse proxy, So I added the config:
# Original configuration
location = / {
proxy_pass http://192.168.12.12:91;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# Added for cache
location ~ \.html {
proxy_pass http://192.168.12.12:91;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache cache_one;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 301 302 1m;
proxy_cache_valid any 1m;
expires 1m;
}
Repeat twice proxy_pass
and proxy_set_header
feel bad
How can I optimize this? Thanks!
You could move this configuration
into a separate file called
proxy.conf
and then include it in the right place