nginx反向代理解決wechat圖片問題

在nginx 中nginx.conf開啓反向代理nginx

 

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/;ide

}spa

會將該域名 http://thirdwx.qlogo.cn/ 替換成 本身的域名下的wechat_image/;從而解決跨域問題!代理

相關文章
相關標籤/搜索