Last active
August 14, 2022 05:24
-
-
Save chenset/62ffe12e9c6f038e54e8685d7e2099c1 to your computer and use it in GitHub Desktop.
Proxy image with nginx
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
server { | |
listen 80; | |
server_name domain.com; | |
merge_slashes off; | |
location ~ /(?<r>http://.*) { | |
resolver 8.8.4.4 8.8.8.8 4.2.2.2 valid=3600s ipv6=off; | |
proxy_set_header Referer ""; | |
proxy_pass $r; | |
expires 10y; | |
} | |
location ~ /(?<r>https://.*) { | |
resolver 8.8.4.4 8.8.8.8 4.2.2.2 valid=3600s ipv6=off; | |
proxy_set_header Referer ""; | |
proxy_pass $r; | |
expires 10y; | |
} | |
} |
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
# https://www.nginx.com/blog/nginx-caching-guide/ | |
proxy_cache_path /tmp/cache levels=1:2 keys_zone=my_cache:100m max_size=10g inactive=7d use_temp_path=off; | |
server { | |
listen 80; | |
server_name domain.com; | |
merge_slashes off; | |
location ~ /(?<r>http://.*) { | |
proxy_cache my_cache; | |
resolver 8.8.4.4 8.8.8.8 4.2.2.2 valid=3600s ipv6=off; | |
proxy_set_header Referer ""; | |
proxy_pass $r; | |
expires 10y; | |
} | |
location ~ /(?<r>https://.*) { | |
proxy_cache my_cache; | |
resolver 8.8.4.4 8.8.8.8 4.2.2.2 valid=3600s ipv6=off; | |
proxy_set_header Referer ""; | |
proxy_pass $r; | |
expires 10y; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can I use: