在中转程序所在服务器添加网站,域名填api.weixin.qq.com

注意:此站点不可与其他应用程序在同一服务器!!!,也就是说中转程序和此站点需要单独放在一个服务器。

然后设置域名SSL证书

密钥(KEY)

-----BEGIN PRIVATE KEY-----
MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQCymY2McDQ/T1Qt
bhQZo6Rox3FDPctq2aI+qxTPrEkRXlOlt2Me9QDOdkY7rKbJVHI6uei3ikzDpkMu
RhK95Rzfmp1IU16toRIeNr+erI/TeY//XUnifiaJnzujgyGz+eiVJBoJ52BKD4Xv
2fLx3tIY/Tm6pEAQeAIaIWH1Q6p1Xo1AmmsS8pZhfCocsNhgmtdAKVxNMGeQsIy5
2GkO8q2Xi5QduI6+Wra88tM603f5HSqRmSqKKJPtcvixWNDtcmUXsBg9QqOk3sXZ
S+LFTAFFqdIBd6/XIWwgFMkdQZhK0WiWrnmxt4KAvRH/k4lu45X7/O3GtoSMgQ/+
HZ9OdFQ3AgMBAAECggEBALGlYJEXLjDm1CDYBDA4gBkkgDlU5teiH+pbuziR8p/P
Bj6oOXSaWDIEnPlQUxmg4HofXyXo71AQOXR2iL/Pe7fCD73YBy2HMAFTjafjlq/P
k3Z6sToTJnvvIaATl9tvsXNfVHMTbMhdxmh7jlYcvzfR8LEAHSUEaXraR5hwtMVG
HJhnB+M/OnpHVpp0oQpR7H6r7SRtQOBbLIc4/hhrSvu8hez9DsGSGQkjjwSUV0/o
TF5+5PnpHVfx4H/dcaiMH92JraWcU1Pv7wtInIUqsOb4Uuinom4KQ6TuHH2BhjZy
ZMU/s6FKQirk3C48lkC52rpGnLBlb53ff2vJeJrxhPECgYEA2rJy/axhHGkx01S8
N9XyR30SednQlMXZGXoR/Z/nCU9wayvZ3bWNJkDGyVTLheASzc+bB1uuAFXmqJRh
ThXddv5gMgzTqQ8xcslGkNktN9/Eeb1VB4It3N31JtiaCrh76h/SUf5XQj1rWrhP
JAiWC6mqqNFIwp5cM49d9bCUQJkCgYEA0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置文件中加入以下代码即可

#==========================================
#以下代码用作微信接口转发
location ^~ /{
proxy_pass https://api.weixin.qq.com;
proxy_set_header Host api.weixin.qq.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
# proxy_hide_header Upgrade;

add_header X-Cache $upstream_cache_status;
#Set Nginx Cache

set $static_fileYZHnjGO9 0;
if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
{
set $static_fileYZHnjGO9 1;
expires 1m;
}
if ( $static_fileYZHnjGO9 = 0 )
{
add_header Cache-Control no-cache;
}
}
location ~ ^/(connect/oauth2/authorize|cgi-bin/token)$ {
proxy_pass http://callback.zhongzhuan.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#==========================================

注意请将代码中标红网址改成自己中转系统的网址