背景

通过 FRP 内网穿透本地的 SpeedTest-X 服务 HTTP 访问时能获取正确的 IP 但 HTTPS 访问时 IP 为127.0.0.1

解决方案

使用Proxy Protocal

# frpc.toml
[[proxies]]
name = "web-https"
type = "https"
localIP = "127.0.0.1"
localPort = 443
customDomains = ...
transport.proxyProtocolVersion = "v2" # 增加
# web.conf
server
{
listen 443 ssl proxy_protocol;
listen [::]:443 ssl proxy_protocol;

set_real_ip_from 127.0.0.1/32; # 此处根据实际情况填写错误的IP段
real_ip_header proxy_protocol;
}