软件下载地址 https://github.com/fatedier/frp/releases
服务端版本 | 客户端版本 |
---|---|
frp_0.46.0_linux_amd64 | frp_0.46.0_windows_amd64 |
服务端配置 frps.ini
[common]
# frp监听的端口,默认是7000,可以改成其他的
bind_port = 7000
# 授权码,请改成更复杂的
token = 12345678
# frp管理后台端口,请按自己需求更改
dashboard_port = 7500
# frp管理后台用户名和密码,请改成自己的
dashboard_user = admin
dashboard_pwd = admin
enable_prometheus = true
# frp日志配置
log_file = /var/log/frps.log
log_level = info
log_max_days = 3
使用 systemctl 控制 frp 服务开机自启
vim /etc/systemd/system/frps.service
[Unit]
Description = frp server
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
# 启动frps的命令,需修改为刚才frp放置的地址
ExecStart = /opt/frp_0.46.0_linux_amd64/frps -c /opt/frp_0.46.0_linux_amd64/frps.ini
[Install]
WantedBy = multi-user.target
启动服务
#1.刷新服务列表
systemctl daemon-reload
#2.设置开机自启
systemctl enable frps
#3.重启系统
reboot
客户端配置 frpc.ini
# 客户端配置
[common]
server_addr = 139.9.123.60
# 与公网配置frps.ini的bind_port一致
authentication_method = token
server_port = 7000
# 与公网配置frps.ini的token一致
token = 12345678
[web1]
type = tcp
local_ip = 127.0.0.1
local_port = 8081
remote_port = 8081
[web2]
type = tcp
local_ip = 127.0.0.1
local_port = 8082
remote_port = 8082
tcp 属于 OSI 传输层,http 属于应用层,type = tcp 也可以使用浏览器访问网站,至此实现了外网ip+端口访问内网服务的功能。
内网地址 | 外网地址 |
---|---|
127.0.0.1:8081 | 139.9.123.60:8081 |
127.0.0.1:8082 | 139.9.123.60:8082 |