[GH-ISSUE #4872] [Feature Request] 本地服务通过frps获取微信accessToken时,微信端获取到的地址不是frps部署的公网ip,这个是怎么回事 #3841

Closed
opened 2026-05-05 14:27:26 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @sunnycxy on GitHub (Jul 8, 2025).
Original GitHub issue: https://github.com/fatedier/frp/issues/4872

Describe the feature request

frps配置:

[common]
# 内网通信穿透通道 监听端口
bind_port = 7000
#token 认证
auth.token = "abcd1234"
#数据传输通道 监听端口
vhost_http_port = 7001

#域名监听
subdomain_host = "mydoamin.com"
# 面板端口
dashboard_port = 7500
# 登录面板的账号密码
dashboard_user = "abc"
dashboard_pwd = "abc.123"

frpc配置:

[common]
serverAddr = "mydomain.com"
# 服务端配置的bindPort
serverPort = 7000

[[proxies]]
# 代理应用名称
name = "wx"
# 代理类型 有tcp\udp\stcp\p2p
type = "http"
# 客户端代理应用IP
localIP = "127.0.0.1"
# 客户端代理应用端口
localPort = 18000
# 服务端反向代理端口;提供给外部访问
customDomains = ["wx.mydomain.com"]
requestHeaders.set.x-from-where = "frp"
responseHeaders.set.foo = "bar"

frps服务器Nginx配置:

server {
        listen 80;
        server_name wx.mydomain.com;

        # frp 代理设置
        location / {
            proxy_pass http://localhost:7001;
            proxy_set_header Host $host;
            #proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            
            # 连接参数优化
            proxy_connect_timeout 75s;
            proxy_send_timeout 1800s;
            proxy_read_timeout 1800s;
            

            # 关闭代理缓冲
            proxy_buffering off;
        }
        
        # 静态文件缓存(可选)
        location ~* \.(js|css|png|jpg|gif|ico|html)$ {
            proxy_pass http://localhost:7001;
            proxy_cache_valid 200 30d;
            add_header X-Cache-Status $upstream_cache_status;
        }
    }

Describe alternatives you've considered

本地应用报错信息:

2025-07-08T23:10:21.782+08:00  INFO 7 --- [wx] [tp1634411546-65] w.c.w.service.AccessTokenService         : 获取token url:https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=appId&secret=mySecret

2025-07-08T23:10:21.848+08:00  INFO 7 --- [wx] [tp1634411546-65] w.c.w.service.AccessTokenService         : 获取token结果:{errcode=40164, errmsg=invalid ip 103.xxx.xxx.161 ipv6 ::xxxxx, not in whitelist rid: xxxxx}

frps部署在阿里云服务器上,ip47开头,添加到了微信公证号ip白名单。这里微信报错提示返回的和公网ip不一致,这个是怎么回事?

Affected area

  • Docs
  • Installation
  • Performance and Scalability
  • Security
  • User Experience
  • Test and Release
  • Developer Infrastructure
  • Client Plugin
  • Server Plugin
  • Extensions
  • Others
Originally created by @sunnycxy on GitHub (Jul 8, 2025). Original GitHub issue: https://github.com/fatedier/frp/issues/4872 ### Describe the feature request frps配置: ``` [common] # 内网通信穿透通道 监听端口 bind_port = 7000 #token 认证 auth.token = "abcd1234" #数据传输通道 监听端口 vhost_http_port = 7001 #域名监听 subdomain_host = "mydoamin.com" # 面板端口 dashboard_port = 7500 # 登录面板的账号密码 dashboard_user = "abc" dashboard_pwd = "abc.123" ``` frpc配置: ``` [common] serverAddr = "mydomain.com" # 服务端配置的bindPort serverPort = 7000 [[proxies]] # 代理应用名称 name = "wx" # 代理类型 有tcp\udp\stcp\p2p type = "http" # 客户端代理应用IP localIP = "127.0.0.1" # 客户端代理应用端口 localPort = 18000 # 服务端反向代理端口;提供给外部访问 customDomains = ["wx.mydomain.com"] requestHeaders.set.x-from-where = "frp" responseHeaders.set.foo = "bar" ``` frps服务器Nginx配置: ``` server { listen 80; server_name wx.mydomain.com; # frp 代理设置 location / { proxy_pass http://localhost:7001; proxy_set_header Host $host; #proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # 连接参数优化 proxy_connect_timeout 75s; proxy_send_timeout 1800s; proxy_read_timeout 1800s; # 关闭代理缓冲 proxy_buffering off; } # 静态文件缓存(可选) location ~* \.(js|css|png|jpg|gif|ico|html)$ { proxy_pass http://localhost:7001; proxy_cache_valid 200 30d; add_header X-Cache-Status $upstream_cache_status; } } ``` ### Describe alternatives you've considered 本地应用报错信息: ``` 2025-07-08T23:10:21.782+08:00 INFO 7 --- [wx] [tp1634411546-65] w.c.w.service.AccessTokenService : 获取token url:https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=appId&secret=mySecret 2025-07-08T23:10:21.848+08:00 INFO 7 --- [wx] [tp1634411546-65] w.c.w.service.AccessTokenService : 获取token结果:{errcode=40164, errmsg=invalid ip 103.xxx.xxx.161 ipv6 ::xxxxx, not in whitelist rid: xxxxx} ``` frps部署在阿里云服务器上,ip47开头,添加到了微信公证号ip白名单。这里微信报错提示返回的和公网ip不一致,这个是怎么回事? ### Affected area - [ ] Docs - [ ] Installation - [ ] Performance and Scalability - [ ] Security - [ ] User Experience - [ ] Test and Release - [x] Developer Infrastructure - [ ] Client Plugin - [ ] Server Plugin - [ ] Extensions - [x] Others
gitea-mirror 2026-05-05 14:27:26 -06:00
Author
Owner

@subei12 commented on GitHub (Jul 9, 2025):

frps 只是把 frpc 暴露到了公网,对微信的请求还是 frpc 发送的
你需要的恐怕是在有公网的服务器上搭建一个 http proxy

<!-- gh-comment-id:3051756455 --> @subei12 commented on GitHub (Jul 9, 2025): frps 只是把 frpc 暴露到了公网,对微信的请求还是 frpc 发送的 你需要的恐怕是在有公网的服务器上搭建一个 http proxy
Author
Owner

@sunnycxy commented on GitHub (Jul 9, 2025):

frps 只是把 frpc 暴露到了公网,对微信的请求还是 frpc 发送的 你需要的恐怕是在有公网的服务器上搭建一个 http proxy

感谢佬解答,是要搭建一个httpproxy,我使用了Nginx代理的,上面有配置,好像是配置的不对,frpc 和 frps使用的是http类型的,应该用tcp

<!-- gh-comment-id:3052603001 --> @sunnycxy commented on GitHub (Jul 9, 2025): > frps 只是把 frpc 暴露到了公网,对微信的请求还是 frpc 发送的 你需要的恐怕是在有公网的服务器上搭建一个 http proxy 感谢佬解答,是要搭建一个httpproxy,我使用了Nginx代理的,上面有配置,好像是配置的不对,frpc 和 frps使用的是http类型的,应该用tcp
Author
Owner

@github-actions[bot] commented on GitHub (Jul 24, 2025):

Issues go stale after 14d of inactivity. Stale issues rot after an additional 3d of inactivity and eventually close.

<!-- gh-comment-id:3111590569 --> @github-actions[bot] commented on GitHub (Jul 24, 2025): Issues go stale after 14d of inactivity. Stale issues rot after an additional 3d of inactivity and eventually close.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#3841
No description provided.