文档:https://gofrp.org/docs/
1、源码下载
wget -P /opt/ https://github.com/fatedier/frp/releases/download/v0.45.0/frp_0.45.0_linux_amd64.tar.gz
2、修改配置文件
cd /opt/
tar xf frp_0.45.0_linux_amd64.tar.gz
ln -s /opt/frp_0.45.0_linux_amd64 /opt/frp
# 修改配置文件
vim /opt/frp/frps.ini
[common]
bind_port = 7000
# dashboard 按需配置
# dashboard_port = 7500
# dashboard_user = admin
# dashboard_pwd = admin
vhost_http_port = 80
vhost_http_port = 443
token = xxxxxxx
subdomain_host = *.xxxxx.com
3、使用 systemd 控制 frps
cat > /etc/systemd/system/frps.service <<EOF
[Unit]
Description = frp server
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
ExecStart = /opt/frp/frps -c /opt/frp/frps.ini
[Install]
WantedBy = multi-user.target
EOF
4、使用 systemd 命令,管理 frps
# 启动frps
systemctl start frps
# 停止frps
systemctl stop frps
# 重启frps
systemctl restart frps
# 查看frps状态
systemctl status frps
# 配置 frps 开机自启
systemctl enable frps
5、frp客户端配置
vim frpc.ini
[common]
server_addr = x.x.x.x # frps所在服务器的公网IP
server_port = 7000
token= xxxxx
vhost_http_port = 80
vhost_http_port = 443
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000
[web1]
type = http
local_ip = 127.0.0.1
local_port = 8080
subdomain = web1.xxxxx.com # web1域名
[web2]
type = https
local_ip = 127.0.0.1
local_port = 443
subdomain = web2.xxxxx.com # web2域名
6、使用 systemd 控制 frpc
cat > /etc/systemd/system/frpc.service <<EOF
[Unit]
Description = frp client
After = network.target syslog.target
Wants = network.target
[Service]
Type = simple
ExecStart = /opt/frp/frpc -c /opt/frp/frpc.ini
[Install]
WantedBy = multi-user.target
EOF
7、使用 systemd 命令,管理 frpc
# 启动frpc
systemctl start frpc
# 停止frpc
systemctl stop frpc
# 重启frpc
systemctl restart frpc
# 查看frpc状态
systemctl status frpc
# 配置 frpc 开机自启
systemctl enable frpc
评论区