proxy_cache_path /var/cache/nginx/proxy_cache_dir/example.com levels=1:2 keys_zone=example.com:100m max_size=700m inactive=6h use_temp_path=off; proxy_buffers 256 16k; proxy_buffer_size 32k; server { listen 80; listen [::]:80; server_name example.com; include snippets/letsencrypt.conf; location / { return 301 https://example.com\$request_uri; } } server { listen 443 ssl http2; listen [::]:443 ssl http2; access_log /var/log/nginx/example.com_access.log; error_log /var/log/nginx/example.com_error.log; server_name example.com; root /var/www/html; # SSL ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; ssl_trusted_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # WordPress cookies (https://www.cookielawinfo.com/wordpress-cookies-list-why-they-are-used/) if ($http_cookie ~* "wordpress_(?!test_cookie)|comment_author_" ) { set $no_cache 1; } # URLs if ($request_uri ~* "/wp-admin/|wp-.*.php|/feed/|/xmlrpc.php|sitemap(_index)?.xml") { set $no_cache 1; } # reverse proxy location / { proxy_cache example.com; proxy_cache_valid 200 304 6h; proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; proxy_cache_bypass $no_cache; proxy_no_cache $no_cache; proxy_cache_background_update on; proxy_cache_lock on; proxy_cache_key $scheme$host$uri; proxy_ignore_headers Expires; proxy_ignore_headers Cache-Control; proxy_pass http://0.0.0.0:8080; include snippets/proxy.conf; } }