和你说一下我的思路吧,停掉公网测试服务器的80和443端口,将测试网站及数据库全部迁移至内网服务器,然后通过frp将内网的80与443端口映射至公网测试服。接下来我试一下实现方法吧
1.frp服务端配置
# wget https://github.com/fatedier/frp/releases/download/v0.36.2/frp_0.36.2_linux_amd64.tar.gz
# tar -xvf frp_0.36.2_linux_amd64.tar.gz
# mv frp_0.36.2_linux_amd64 /usr/local/frp
# vi /usr/local/frp/frps.ini
[common]
bind_port = 7000
dashboard_port = 7500
dashboard_user = admin
dashboard_pwd = ******
log_file = /var/log/frps.log
log_level = info
log_max_days = 7
vhost_http_port = 80
vhost_https_port = 443
token = jeRgfgf
2.使用systemd管理frp服务
# cp /usr/local/frp/systemd/frps.service /etc/systemd/system/
# vi /etc/systemd/system/frps.ini
[Unit]
Description=Frp Server Service
After=network.target
[Service]
Type=simple
User=root
Restart=on-failure
RestartSec=5s
ExecStart=/usr/local/frp/frps -c /usr/local/frp/frps.ini
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl start frps && systemctl enable frps
3.客服端配置
# wget https://github.com/fatedier/frp/releases/download/v0.36.2/frp_0.36.2_linux_amd64.tar.gz
# tar -xvf frp_0.36.2_linux_amd64.tar.gz
# mv frp_0.36.2_linux_amd64 /usr/local/frp
# vi /usr/local/frp/frpc.ini
[common]
server_addr = **********
server_port = 7000
token = jeRgfgf
[mysql]
type = tcp
local_ip = 127.0.0.1
local_port = 3306
remote_port = 3306
[apiygj01]
type = http
local_ip = 127.0.0.1
local_port = 80
custom_domains = apidev.test.com
[apiygj02]
type = https
local_ip = 127.0.0.1
local_port = 443
custom_domains = apidev.test.com
[demo01]
type = http
local_ip = 127.0.0.1
local_port = 80
custom_domains = demo.test.com
[demo02]
type = https
local_ip = 127.0.0.1
local_port = 443
custom_domains = demo.test.com
使用systemd管理frp服务
# cp /usr/local/frp/systemd/frpc.service /etc/systemd/system/
# vi /etc/systemd/system/frpc.ini
[Unit]
Description=Frp Client Service
After=network.target
[Service]
Type=simple
User=root
Restart=on-failure
RestartSec=5s
ExecStart=/usr/local/frp/frpc -c /usr/local/frp/frpc.ini
ExecReload=/usr/local/frp/frpc reload -c /usr/local/frp/frpc.ini
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start frpc && systemctl enable frpc