Nginx-proxy: how to enable caching?

Created on 24 Apr 2017  路  4Comments  路  Source: nginx-proxy/nginx-proxy

Hello, for me it's not clear how to enable caching.
I need to use the call from letsencrypt
docker run -d -p 80:80 -p 443:443 -v /path/to/certs:/etc/nginx/certs:ro -v /etc/nginx/vhost.d -v /usr/share/nginx/html -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy

and add the files:
/etc/nginx/conf.d/my_proxy.conf
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=my_cache:10m max_size=10g;

/etc/nginx/vhost.d/\ proxy_cache my-cache; proxy_cache_valid 200 302 60m; proxy_cache_valid 404 1m;

then i start letsencrypt:
docker run -d -v /path/to/certs:/etc/nginx/certs:rw --volumes-from nginx-proxy -v /var/run/docker.sock:/var/run/docker.sock:ro jrcs/letsencrypt-nginx-proxy-companion

and last the service:
docker run -it -v $(pwd):/data -e VIRTUAL_HOST=<myDomainName> klokantech/tileserver-gl -c config.json

This works so far, but caching looks disabled.
I'm new on docker, so for me it's not clear where to set which config.
And also one question for me; the pathes like /path/to/certs:/, are this pathes on the lokal system?
Will the conf.d and vhost.d files automatically loaded?

Would be nice to get some little help

Most helpful comment

You need to set proxy_buffering on; in your location block as mentioned in #241.

All 4 comments

I think you followed the right steps and I followed similar ones but I experience the same.
If I look inside nginx-proxy container for the cache files (/var/cache/nginx in your case) there is nothing and cache don't seem to have any effect.

any update on that one?

You need to set proxy_buffering on; in your location block as mentioned in #241.

proxy_cache_valid any 48h; solved it for me

Was this page helpful?
0 / 5 - 0 ratings