码迷,mamicode.com
首页 > 其他好文 > 详细

nginx反向代理解决wechat图片问题

时间:2019-02-25 18:36:30      阅读:380      评论:0      收藏:0      [点我收藏+]

标签:red   重启nginx   proxy   show   requested   agent   opened   pre   ons   

在nginx 中nginx.conf开启反向代理

 

技术图片
1   location ^~ /wechat_image/ {
2             add_header Access-Control-Allow-Origin "$http_origin" always;
3             add_header Access-Control-Allow-Credentials true always;
4             add_header Access-Control-Allow-Methods GET, OPTIONS always;
5             add_header Access-Control-Allow-Headers Accept,Authorization,Cache-Control,Content-Type,DNT,If-Mod    ified-  Since,Keep-Alive,Origin,User-Agent,X-Requested-With always;
6             proxy_pass http://thirdwx.qlogo.cn/;
7 
8             }
vhost下具体文件中的配置

然后重启nginx 即可;

location ^~ /wechat_image/ {
add_header ‘Access-Control-Allow-Origin‘ "$http_origin" always;
add_header ‘Access-Control-Allow-Credentials‘ ‘true‘ always;
add_header ‘Access-Control-Allow-Methods‘ ‘GET, OPTIONS‘ always;
add_header ‘Access-Control-Allow-Headers‘ ‘Accept,Authorization,Cache-Control,Content-Type,DNT,If-Mod ified- Since,Keep-Alive,Origin,User-Agent,X-Requested-With‘ always;
proxy_pass http://thirdwx.qlogo.cn/;

}

会将该域名 http://thirdwx.qlogo.cn/ 替换成 自己的域名下的wechat_image/;从而解决跨域问题!

nginx反向代理解决wechat图片问题

标签:red   重启nginx   proxy   show   requested   agent   opened   pre   ons   

原文地址:https://www.cnblogs.com/rianley/p/10432341.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!