![Nginx 代理服务器缓存来自 apache 服务器的图像](https://linux22.com/image/662834/Nginx%20%E4%BB%A3%E7%90%86%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%BC%93%E5%AD%98%E6%9D%A5%E8%87%AA%20apache%20%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E5%9B%BE%E5%83%8F.png)
我有 2 台服务器,一台 apache,一台 nginx。
我设置 nginx 作为代理
location / {
proxy_pass http://apachesample.com:8080/;
include /etc/nginx/conf.d/proxy.conf;
proxy_buffering off;
proxy_cache web-cache;
proxy_cache_valid 200 302 60m;
proxy_cache_valid 404 1m;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
// try to add this section to add header and cache image
location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
expires max;
add_header Pragma public;
#add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
}
当我尝试添加 expries 标题时,没有找到所有图像?
如何设置图像的缓存过期标头?我必须在 Apache 服务器上执行此操作吗?
修复:启用 mod_rewrite