Last active
February 15, 2025 12:15
-
-
Save kasparsd/8ff6bad037307e426cc766ef8f3ff2fa to your computer and use it in GitHub Desktop.
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
proxy_cache_path /var/cache/cf-images levels=1:2 keys_zone=CF_IMAGES:10m inactive=7d max_size=10MB; | |
server { | |
# ... here goes the rest of your config. | |
# Proxy example.com/cfimg/original/path/image.jpg?cf=width=100,quality=80 | |
# to example.com/cdn-cgi/image/width=100,quality=80/original/path/image.jpg | |
location ~* ^/cfimg/(.*)$ { | |
resolver 1.1.1.1; | |
proxy_pass https://your-cloudflare-domain.com/cdn-cgi/image/$arg_cf/$1; | |
add_header X-CF-Cache $upstream_cache_status; | |
proxy_cache CF_IMAGES; | |
proxy_cache_key "$host$request_uri$http_accept"; | |
proxy_cache_valid 200 30d; | |
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment