工作需求:
公司的腾讯云服务器IP是固定的,本地服务器IP不断变化。需要将本地服务器的tomcat通过内网穿透的形式映射到云服务器上,使用户可以通过访问云服务器的IP或者域名直接访问。
服务器版本:
openEuler-22.03-LTS
frp软件版本:
frp-0.57
github下载地址:Release v0.57.0 · fatedier/frp · GitHub
中文文档:文档 | frp
配置文件:
配置文件json格式
server端:
修改frps.toml
#服务端进程监听端口
bindPort = 7000
#用于反向代理http主机
vhosHTTPPort = 80
#鉴权方式
auth.method = "token"
#客户端连接的token
auth.tonken = "password"
#后台管理配置
webServer.addr = "0.0.0.0"
webServer.port = 7800
webServer.user = "admin"
webServer.password = "password"
#日志配置:
log.to = "/var/log/frps.log"
log.devel = "info"
log.maxDays = "3"
client端:
修改frpc.toml
#连接服务端
serverAddr = "server端IP"
serverPort = 7000
auth.method = "token"
auth.token = "password"
#http代理:
[[proxies]]
name = "web"
type = "tcp"
localIP = "127.0.0.1"
localPort = 80
remotePort = 88
#mysql端口内网穿透
[[proxies]]
name = "mysql"
type = "tcp"
localIP = "127.0.0.1"
localPort = 3306 #本地监听端口
remotePort = 3307 #服务端监听端口
配置启动脚本:
server端:
/usr/lib/systemd/system/frps.server
[Unit]
Description = frp server
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
ExecStart = /path to frp/frps -c /path to frp/ frps.toml
[Install]
WantedBy = multi-user.target
systemctl daemon-reload
systemctl enable frps.service && systemctl start frps.service
client端:
/usr/lib/systemd/system/frpc.server
[Unit]
Description = frp client
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
ExecStart = /path to frp/frpc -c /path to frp/ frpc.toml
[Install]
WantedBy = multi-user.target
systemctl daemon-reload
systemctl enable frpc.service && systemctl start frpc.service
后台管理界面:
访问地址:http://[serverAddr]:7800