首先的有一个可以使用公网IP的服务器。
先下载 wget https://github.com/fatedier/frp/releases/download/v0.13.0/frp_0.13.0_linux_amd64.tar.gz
解压tar -zxvf frp_0.13.0_linux_amd64.tar.gz
配置服务端
[common]
bind_addr = 0.0.0.0
bind_port = 8999
bind_udp_port = 8999
kcp_bind_port = 8999
vhost_http_port = 8080
vhost_https_port = 8443
token = 123456789
配置客户端
[common]
server_addr = 47.103.122.205
server_port = 8999
token = 123456789
; ssh
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 8998
;redis
[redis]
type = tcp
local_ip = 127.0.0.1
local_port = 46379
remote_port = 8997
; mysql_m
[mysql_m]
type = tcp
local_ip = 127.0.0.1
local_port = 43306
remote_port = 8996
; mysql_s
[mysql_s]
type = tcp
local_ip = 127.0.0.1
local_port = 43307
remote_port = 8995
; zookeeper
[zookeeper]
type = tcp
local_ip = 127.0.0.1
local_port = 42181
remote_port = 8994
; kafka_1
[kafka_1]
type = tcp
local_ip = 127.0.0.1
local_port = 49091
remote_port = 8993
; kafka_2
[kafka_2]
type = tcp
local_ip = 127.0.0.1
local_port = 49092
remote_port = 8992
; kafka_3
[kafka_3]
type = tcp
local_ip = 127.0.0.1
local_port = 49093
remote_port = 8991
[web1]
type = http
local_port = 80
custom_domains = xypj.xyz
[web2]
type = http
local_port = 80
custom_domains = cc.xypj.xyz
然后设置自动启动,使用systemctl管理。
服务端
vim /lib/systemd/system/frps.service
[Unit]
Description=fraps service
After=network.target syslog.target
Wants=network.target
[Service]
Type=simple
#启动服务的命令(此处写你的frps的实际安装目录)
ExecStart=/your/path/frps -c /your/path/frps.ini
[Install]
WantedBy=multi-user.target
客户端
vim /lib/systemd/system/frpc.service
[Unit]
Description=frapc service
After=network.target syslog.target
Wants=network.target
[Service]
Type=simple
#启动服务的命令(此处写你的frps的实际安装目录)
ExecStart=/your/path/frpc -c /your/path/frpc.ini
[Install]
WantedBy=multi-user.target
然后
systemctl start frps
systemctl start frpc
systemctl enable frps
systemctl enable frpc
如果要重启应用,可以这样,sudo systemctl restart frps
如果要停止应用,可以输入,sudo systemctl stop frps
如果要查看应用的日志,可以输入,sudo systemctl status frps