- frp0.52以后的版本配置文件是按照json格式编写的
下载frp
frp的github地址:https://github.com/fatedier/frp
上传到服务端和客户端,然后解压
服务端用到的文件是frps
和配置文件frps.ini
服务端修改配置frps.ini
[common]
bind_port = 7000
authentication_method = token
token = 123456
客户端用到的文件是frpc
和配置文件frpc.ini
客户端修改配置frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
tls_enable = true
token = 123456
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000
local_ip 和 local_port 配置为本地需要暴露到公网的服务地址和端口。remote_port 表示在 frp 服务端监听的端口,访问此端口的流量将会被转发到本地服务对应的端口。
做成linux服务,使用systemctl管理
服务端新建文件并编辑
cat << EOF > /etc/systemd/system/frps.service
[Unit]
Description = frp server
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
ExecStart = /root/frp/frps -c /root/frp/frps.ini
[Install]
WantedBy = multi-user.target
EOF
systemctl daemon-reload
systemctl enable frps
systemctl start frps
客户端新建文件并编辑
cat << EOF > /etc/systemd/system/frpc.service
[Unit]
Description = frp client
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
ExecStart = /root/frp/frpc -c /root/frp/frpc.ini
[Install]
WantedBy = multi-user.target
EOF
systemctl daemon-reload
systemctl enable frpc
systemctl start frpc
以下为新版本配置
v0.54配置文件
服务端配置文件
# 服务端口
bindPort = 7000
# 鉴权方式
auth.method = "token"
# token值,客户端需要配置一致
token = "123456"
# HTTP 类型代理
vhostHTTPPort = 80
# HTTPS 类型代理
vhostHTTPSPort = 443
# Dashboard 配置
webServer.addr = "0.0.0.0"
webServer.port = 7001
webServer.user = "admin"
webServer.password = "admin"
客户端配置文件
serverAddr = "x.x.x.x"
serverPort = 7000
token = "123456"
[[proxies]]
name = "ssh"
type = "tcp"
localIP = "127.0.0.1"
localPort = 22
remotePort = 20001
[[proxies]]
name = "web"
type = "tcp"
localIP = "127.0.0.1"
localPort = 443
remotePort = 20001
做成linux服务,使用systemctl管理
服务端新建文件并编辑
cat << EOF > /etc/systemd/system/frps.service
[Unit]
Description = frp server
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
ExecStart = /root/frp/frps -c /root/frp/frps.toml
[Install]
WantedBy = multi-user.target
EOF
systemctl daemon-reload
systemctl enable frps
systemctl start frps
客户端新建文件并编辑
cat << EOF > /etc/systemd/system/frpc.service
[Unit]
Description = frp client
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
ExecStart = /root/frp/frpc -c /root/frp/frpc.toml
[Install]
WantedBy = multi-user.target
EOF
systemctl daemon-reload
systemctl enable frpc
systemctl start frpc