美文网首页
nginx代理访问图片的方法

nginx代理访问图片的方法

作者: 拖着蜗牛看风景 | 来源:发表于2019-06-20 15:19 被阅读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;
}

这样就可以访问图片了。

相关文章

网友评论

      本文标题:nginx代理访问图片的方法

      本文链接:https://www.haomeiwen.com/subject/safjqctx.html