nginx代理访问图片的方法

2019-06-20  本文已影响0人  拖着蜗牛看风景

之前在项目部署的时候,需要将图片代理到服务器上面。以前我们正常代理的方法为:

 location /images {
       root /data/images;
 }

这个在服务器上面可以正常访问。但是今天在本地配置的时候,是在显示为404。查看错误日志为:

 [error] 14736#3864: *3506 WSARecv() failed (10053: An established connection was aborted by the software in your host machine) while reading response header from upstream, client: 127.0.0.1, server: 192.168.22.34,

后面分析后,发现需要在配置文件中增加rewrite,其配置文件更改为:

 location /images {
  rewrite ^/images/(.*)$ /$1 break;
  root /data/images;
}

这样就可以访问图片了。

上一篇 下一篇

猜你喜欢

热点阅读