Here's a working configuration for setting up NGINX for caching site https://www.uta.fi.
events { worker_connections 4096; ## Default: 1024 } http { proxy_cache_path /tmp/nginx-proxy levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=1y use_temp_path=off; proxy_hide_header Set-Cookie; proxy_ignore_headers Set-Cookie; server { listen 80; location / { proxy_send_timeout 180s; proxy_read_timeout 180s; proxy_cache my_cache; proxy_cache_valid 200 1y; proxy_pass https://www.uta.fi; } } }
This configuration stores up to 10GB of cached data for 1 year. The local cache path is set to existing directory /tmp/nginx-proxy.
To use NGINX, you don't have to install it locally. I prefer using Docker images. You can run the example above with the following command.
docker run -d --rm -p 1001:80 --name nginx-cache \ -v /tmp/proxy-blog/nginx-proxy.conf:/etc/nginx/nginx.conf:ro \ -v /tmp/proxy-blog/proxy-local-directory:/tmp/nginx-proxy nginx
After the command, point your browser at http://localhost:1001 and see the results. The command assumes that you have saved the NGINX configuration listed above as /tmp/proxy-blog/nginx-proxy.conf and that you have directory /tmp/proxy-blog/proxy-local-directory on your computer (the Docker host).