当前位置:网站首页 / FRP教程 / 正文

frpc通过WEB获取访客真实IP

时间:2018年03月15日 | 作者 : liuhui | 分类 : FRP教程 | 浏览: 10755次 | 评论 0

阿里云限量代金券 | 此广告位出租25元/月

我们用frp穿透到自己做的网站上,然而当访客访问到这网站上,却不是访客他们自己的真实IP来源,而是 frps服务器的IP。


frp支持X-Real-IP代理转发,只有用http和https协议支持。


(这里指的是frpc客户端使用frp内网穿透服务,获取web访客真实IP,而不是在frps服务端设置。)


以Nginx为例,让你的web获取访客真实IP,而非frp的IP。


先看你的nginx有没有安装这个Realip模块,

先通过 nginx -V 命令查看

--with-http_realip_module 显示有这个

没有的话,自己重新添加上编译过。


在你的nginx.conf的http{}部分添加

set_real_ip_from frps服务端的IP; 

例如:set_real_ip_from 192.168.1.1;


然后在你的nginx网站server配置中location部分内,添加下面这


real_ip_header X-Real-IP;

real_ip_recursive on;

以Lighttpd为例,让你的web获取访客真实IP,而非frp的IP。


lighttpd.conf添加以下代码:


server.modules  = ("mod_access","mod_accesslog","mod_extforward")

$HTTP["remoteip"] == "FRP服务端IP" {extforward.forwarder = ( "all" => "trust" )extforward.headers = ("X-Real-IP")}

apache也支持,需要安装模块 mod_rpaf 和添加参数,具体教程网上自行搜索。本文章则不再介绍。

推荐您阅读更多有关于“”的文章

猜你喜欢

网站分类
关注电脑博士
友情链接

分享:

支付宝

微信