【发布时间】:2015-05-29 17:36:27
【问题描述】:
我在让 NGINX 缓存我使用 proxy_pass 命令从 Dropbox 提取的缩略图时遇到问题。在 NGINX 运行的同一台服务器上,我多次运行以下命令
wget --server-response --spider http://localhost:8181/1/thumbnails/auto/test.jpg?access_token=123
使用 X-Cache: MISS 每次都得到完全相同的响应
HTTP/1.1 200 正常 服务器:nginx/1.1.19 日期:格林威治标准时间 2015 年 3 月 25 日星期三 20:05:36 内容类型:图片/jpeg 内容长度:1691 连接:保持活动 杂注:无缓存 缓存控制:无缓存 X-Robots-标签:noindex、nofollow、noimageindex X-Cache:MISS
这是我的 nginx.conf 文件的内容......关于我在这里做错了什么有什么想法吗?
## Proxy Server Caching
proxy_cache_path /data/nginx/cache keys_zone=STATIC:10m max_size=1g;
## Proxy Server Setting
server {
listen *:8181;
proxy_cache STATIC;
proxy_cache_key "$request_uri";
proxy_cache_use_stale error timeout invalid_header updating
http_500 http_502 http_503 http_504;
location ~ ^/(.*) {
set $dropbox_api 'api-content.dropbox.com';
set $url '$1';
resolver 8.8.8.8;
proxy_set_header Host $dropbox_api;
proxy_cache STATIC;
proxy_cache_key "$request_uri";
proxy_cache_use_stale error timeout invalid_header updating
http_500 http_502 http_503 http_504;
add_header X-Cache $upstream_cache_status;
proxy_pass https://$dropbox_api/$url$is_args$args;
}
##Error Handling
error_page 500 502 503 504 404 /error/;
location = /error/ {
default_type text/html;
}
}
【问题讨论】: