Last active
July 14, 2023 04:47
-
-
Save wention/e0169f24265282c041ead4c2f85b3950 to your computer and use it in GitHub Desktop.
HTTP 反向代理与缓存
This file contains hidden or 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
user nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log notice; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
proxy_cache_path /cache levels=1:2 keys_zone=mirrorcache:10m max_size=500m inactive=7d; | |
proxy_cache_revalidate on; | |
#map $request_method $purge_method { | |
# PURGE 1; | |
# default 0; | |
#} | |
server { | |
listen 80; | |
proxy_cache mirrorcache; | |
proxy_cache_key $uri$is_args$args; | |
#proxy_cache_purge $purge_method; | |
location / { | |
proxy_pass http://mirrors.ustc.edu.cn/; | |
# 设置缓存时间 | |
proxy_cache_valid any 1m; | |
add_header X-Cache-Hit $upstream_cache_status; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment