Last active
July 11, 2023 17:08
-
-
Save DaanV2/c039e3af07f64e618fb105b476d2982c to your computer and use it in GitHub Desktop.
Nginx reverse proxy cache, connecting to a static file provider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Declare a cache named static-cache | |
proxy_cache_path /data/nginx/cache levels=1:2 keys_zone=static-cache:2m max_size=100m inactive=7d use_temp_path=off; | |
proxy_cache_key $scheme$proxy_host$request_uri; | |
proxy_cache_lock on; | |
proxy_cache_use_stale updating; | |
server { | |
listen 80; | |
server_name _; | |
sendfile on; | |
sendfile_max_chunk 1m; | |
keepalive_timeout 60; | |
location / { | |
proxy_buffering on; | |
proxy_cache static-cache; | |
proxy_cache_valid 404 1m; | |
proxy_cache_use_stale error timeout updating http_404 http_500 http_502 http_503 http_504; | |
proxy_cache_bypass $http_x_purge; | |
add_header X-Cache-Status $upstream_cache_status; | |
add_header X-Content-Type-Options nosniff; | |
proxy_pass http://<master-server>; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment