使用nginx缓存本地静态文件,由同一个nginx来解析。
复制代码代码如下:
upstream local_img {
(责任编辑:IT)server localhost:81; } server{ listen 81; server_name 127.0.0.1; location / { root /image/; client_max_body_size 10m; access_log off; autoindex off; } } server { listen 80; server_name img.test.com; proxy_cache cache_one; location / { proxy_redirect off; proxy_cache_valid 200 304 12h; proxy_cache_valid 301 302 1m; proxy_cache_key $host$uri$is_args$args; add_header X-Cache $upstream_cache_status; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_pass http://local_img; access_log off; } } |