frp内网穿透

本文介绍了frp内网穿透工具的下载、服务端(frps.ini)与客户端(frpc.ini)的配置方法,涵盖TCP、HTTP、HTTPS穿透示例,包括SSL证书配置、子域名映射、远程桌面等场景,并说明了如何通过proxy_protocol获取用户真实IP。

作者:zhuge···预计阅读 11 分钟·636 阅读·0 评论
frp内网穿透

下载 https://github.com/fatedier/frp/releases

服务端 frps.ini

[common]
bind_port = 7000 #绑定端口,就是客户端连接到服务端时的端口
#token = 111222 #token,就是客户端连接到服务端时的鉴权
dashboard_port = 7500 #访问服务端面板的端口
dashboard_user = zhuge #访问服务端面板的账号
dashboard_pwd = 123456 #访问服务端面板的密码
#vhost_http_port = 80 #http穿透端口
#vhost_https_port = 443 #https穿透端口
heartbeat_timeout = 90

客户端

[common]
server_addr = x.x.x.x
server_port = 7000

[web]
type = tcp
local_ip = 127.0.0.1
local_port = 88
remote_port = 6250
#custom_domains=o.vxlife.com
#vhost_http_port

当客户端使用 tcp时,不需要定义vhost_http_port 服务器端可以直接使用x.x.x.x:6250访问 其它SSL配置如下

[common]
server_addr = frp3.freefrp.net
server_port = 7000
token = freefrp.net
#server_addr = frp.104300.xyz
#server_port = 7000
#token = www.126126.xyz

[vxera_http]
type = http
local_ip = 127.0.0.1
local_port = 88
custom_domains = c.vxera.com


[vxera_https]
type = https
local_ip = 127.0.0.1
local_port = 443
custom_domains = c.vxera.com
use_encryption = true
use_compression = true
[common]
server_addr = 192.168.100.100                    #服务端的IP地址,好像也可以写域名,没试过
server_port = 7000                               #服务端端口

[test_http]                                      #Http服务,映射的是服务端http80端口
type = http                                      #服务方式
local_ip = 127.0.0.1                             #服务端ip,可写本地,局域网等做反向代理的ip
local_port = 8000                                #服务端端口
custom_domains = test.test.com                   #需要反向代理的域名,就是服务端要代理的域名

[test_https]                                     #Https服务,映射的是服务端https443端口
type = https                                     #服务方式
local_ip = 127.0.0.1                             #服务端ip,可写本地,局域网等做反向代理的ip
local_port = 8000                                #服务端端口
custom_domains = test.test.com                   #需要反向代理的域名,就是服务端要代理的域名

# 以下为https新加的内容
plugin = https2http                             #将 https请求转换成http请求后再发送给本地服务
plugin_local_addr = 127.0.0.1:8000              #转换http后的端口  

#证书相关配置
plugin_crt_path = /fullchain1.crt  #linux下生成的证书为fullchain.pem格式,复制到Windows上改成.crt后缀即可
plugin_key_path = /privkey1.key    #linux下生成的证书为privkey.pem格式,复制到Windows上改成.key后缀即可
plugin_host_header_rewrite = 127.0.0.1            
plugin_header_X-From-Where = frp

frp.104300.xyz 示例

[common]
server_addr = frp.104300.xyz
server_port = 7000
token = www.126126.xyz

# 注意下面的yourname要取一个和别人不重复的名字,名称冲突会启动失败

# http示例
[yourname_http]
type = http
local_ip = 192.168.0.2
local_port = 5000
# 自己的域名
custom_domains = nas.yourdomain.com
# 子域名(不要和别人重复)
subdomain = nas

# https示例
[yourname_https]
type = https
local_ip = 192.168.0.2
local_port = 5001
custom_domains = nas.yourdomain.com
subdomain = nas

# ssh示例
[yourname_linux_ssh]
type = tcp
local_ip = 192.168.0.3
local_port = 22
remote_port = 22222

# 远程桌面示例
[yourname_windows10_rdp]
type = tcp
local_ip = 192.168.0.4
local_port = 3389
remote_port = 33333

使用frp内网穿透时获取用户的真实ip 在frpc.ini中修改如下:

[https web]
type = https
local_port = 443
custom_domains = a.imbs.top
# 目前支持 v1 和 v2 两个版本的 proxy protocol 协议。
proxy_protocol_version = v2

nginx在listen段添加proxy_protocol,然后配置real_IP_header为 proxy_protocol,具体如下:

server {
  listen 443 ssl http2 proxy_protocol;
  real_ip_header proxy_protocol;
  real_ip_recursive on;
  set_real_ip_from 192.168.0.1;
  ……
}

相关文章

评论

加载中...