如何搭建FRP,可参考以前的文章

Ubuntu 18.04 使用FRP内网穿透,映射内网Web服务至公网

上篇内容新增upfrpc.sh 进程检测(自动启动)
 1    # crontab 计划任务配置: */1 * * * * sh /upfrpc.sh
 2    #!/bin/sh
 3
 4    PIDS=`ps -ef |grep "frpc.ini" |grep -v grep | awk '{print $1}'`
 5    if [ "$PIDS" == "" ]; then
 6        #运行进程
 7
 8        nohup /frp/frpc -c /frp/frpc.ini &
 9        echo "进程不存在"
10        exit 0;
11    fi
12    echo "进程存在"
13    exit 0;
上篇内容新增upfrps.sh 进程检测(自动启动)
 1    # crontab 计划任务配置: */1 * * * * sh /upfrps.sh
 2    #!/bin/sh
 3
 4    PIDS=`ps -ef |grep "frps.ini" |grep -v grep | awk '{print $1}'`
 5    if [ "$PIDS" == "" ]; then
 6        #运行进程
 7
 8        nohup /frp/frps -c /frp/frps.ini &
 9        echo "进程不存在"
10        exit 0;
11    fi
12    echo "进程存在"
13    exit 0;

映射80、443端口的配置

1web由Docker + traefik + nginx等提供服务(80,443)

frpc.ini(客户端)

 1[common]
 2
 3server_addr = 120.*.*.*
 4server_port = 7000
 5
 6vhost_http_port=80
 7vhost_https_port=443
 8
 9
10[web_gitlab_80]
11type = http
12local_port = 80
13custom_domains = gitlab.halobug.cn
14
15[web_www_443]
16type = https
17local_port = 443
18custom_domains = www.halobug.cn
19
20[ssh]
21type = tcp
22local_ip = 127.0.0.1
23local_port = 22
24remote_port = 6000

frps.ini(服务端)

1[common]
2bind_port = 7000
3vhost_http_port = 80
4vhost_https_port=443
5# dashboard & 设置密码
6dashboard_addr = 0.0.0.0
7dashboard_port = 7500
8dashboard_user = uname
9dashboard_pwd = upwd

顺利启动,看到以下截图!

Xnip2022-04-19_15-26-07

Xnip2022-04-19_15-26-17

Xnip2022-04-19_15-26-37

Xnip2022-04-19_15-26-31