frp使用记录
最近公司停了使用了很久的专线网络,很多映射失效,用了frp来暂时替代了几个必须的外网访问。本来就有好几台阿里云服务器,正好作服务端。
frp是什么,就不多介绍了,容易误伤。
下载地址:https://github.com/fatedier/frp/releases
服务端配置:
#vi frps.ini [common] bind_port = 7000 max_pool_count = 5 vhost_http_port = 80 vhost_https_port = 443 token = 123456 dashboard_port = 7500 # dashboard 用户名密码 dashboard_addr = 0.0.0.0 dashboard_port = 7500 dashboard_user = admin dashboard_pwd = 123456
客户端配置:
#vi frpc.ini server_addr = 202.202.202.202 server_port = 7000 token = 123456 [web01] type = https local_ip = 127.0.0.1 local_port = 8088 custom_domains = www.xxx.com [web02] type = https local_ip = 192.168.0.7 local_port = 443 custom_domains = gw.test.xxx.com [web03] type = http local_ip = 192.168.0.5 local_port = 80 custom_domains = new1.test.xxx.com [web04] type = http local_ip = 192.168.0.8 local_port = 80 custom_domains = new2.test.xxx.com [ssh] type = tcp local_ip = 127.0.0.1 local_port = 22 remote_port = 6000 [sit01] type = tcp local_ip = 127.0.0.1 local_port = 17443 remote_port = 17443
启动命令:
#服务端 ./frps -c frps.ini 后台启动 nohup ./frps -c frps.ini & #客户端 ./frpc -c frpc.ini 后台启动 nohup ./frpc -c frpc.ini &
总结一下:
vhost_http_port = 80
vhost_https_port = 443这两个参数客户端可以使用type=http/https,是为了满足同端口不同域名的情况。
但如果内部有其它端口网站,适合上面同一端口配置的情况,可以直接使用type=tcp模式来配置,访问方式:http(s)://www.youdomain.com:17443/