问题
开发微信接口的时候发现TOKEN请求必须从IP白名单列表里的IP发出才行
解决
使用nginx反向代理轻松搞定
server{
listen 80;
server_name www.debug.com;
location /proxy/ {
proxy_pass https://api.weixin.qq.com/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#有可能会造成未知影响,先屏蔽掉
#proxy_set_header Host $host;
}
}
效果
正常请求URL:
https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET
现在请求URL:
http://www.debug.com/proxy/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET