FRP获取用户真实IP地址

FRP默认获取到用户的IP地址是127.0.0.1,按以下方法获得用户真实IP地址

1.添加proxy_protocol_version = v2

[[proxies]]
name = "web"
type = "https"
localIP = "127.0.0.1"
localPort = 443
# 目前支持 v1 和 v2 两个版本的 proxy protocol 协议。
proxy_protocol_version = v2

2.listen端口后添加proxy_protocol

server {
  listen 80 proxy_protocol;
  listen 443 ssl http2 proxy_protocol;
  ……
}

3.在nginx配置文件中的root后添加以下代码

 real_ip_header proxy_protocol;
 real_ip_recursive on;
 set_real_ip_from 127.0.0.1;

文档仓库 » FRP获取用户真实IP地址