配置服务端:
解压到指定文件夹:
tar -xzvf frp_0.33.0_linux_amd64.tar.gz -C /usr/local
配置服务,设置开机自启动:
vim /usr/lib/systemd/system/frp.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=simple
ExecStart=/usr/local/frp_0.33.0_linux_amd64/frps -c /usr/local/frp_0.33.0_linux_amd64/frps.ini
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
StandardOutput=syslog
StandardError=inherit
[Install]
WantedBy=multi-user.target
systemctl daemon-reload # 重载服务
systemctl enable frp #设置frp开机自启动
systemctl start frp #启动frp服务
systemctl status frp #查看frp服务状态
修改配置文件:
vim /usr/local/frp_0.33.0_linux_amd64/frps.ini
[common]
bind_port = 10000 #服务端连接客户端的端口
dashboard_port = 10001 #服务端仪表板面板的端口
token = xxxx #服务端连接客户端的口令
dashboard_user = admin #仪表板页面登录的用户名
dashboard_pwd = xxx #仪表板页面登录的密码
vhost_http_port = 10002 #HTTP主机使用的端口
vhost_https_port = 10003 #HTTPS主机使用的端口
配置客户端:
与服务端类似,配置的文件不一样。
vim /usr/lib/systemd/system/frpc.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=simple
ExecStart=/usr/local/frp_0.33.0_linux_amd64/frpc -c /usr/local/frp_0.33.0_linux_amd64/frpc.ini
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
StandardOutput=syslog
StandardError=inherit
[Install]
WantedBy=multi-user.target
systemctl daemon-reload # 重载服务
systemctl enable frpc #设置frpc开机自启动
systemctl start frpc #启动frpc服务
systemctl status frpc #查看frpc服务状态
firewall-cmd --zone=public --add-port=10000-10090/tcp --permanent # 端口段放行
firewall-cmd --zone=public --add-port=8080/tcp --permanent #单个端口放行
firewall-cmd --reload
关于端口放行,也可以直接查看:
vim /etc/firewalld/zones/public.xml
1
内容如下:
<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
<service name="ssh"/>
<service name="dhcpv6-client"/>
<service name="https"/>
<port protocol="tcp" port="3306"/>
<port protocol="tcp" port="9000"/>
<port protocol="tcp" port="80"/>
<port protocol="tcp" port="27017"/>
<port protocol="tcp" port="9501"/>
<port protocol="tcp" port="6379"/>
<port protocol="tcp" port="8080"/>
<port protocol="tcp" port="8081"/>
<port protocol="tcp" port="8082"/>
<port protocol="tcp" port="8083"/>
<port protocol="tcp" port="10000-10090"/>
</zone>
如果用的云服务器,记得放行对应的端口,也就是服务器上防火墙要放行,云服务器控制台也要设置安全组,这样才能真正放行。
测试通过:
配置域名需要解析到frpserver所在的服务器上。
在本地配置多个web站点:
[common]
server_addr = xxx
server_port = xxx
token = xxx
[web00]
type = http
local_port = 8080
custom_domains = frp1.xxx.cn
[web01]
type = http
local_port = 8081
custom_domains = frp2.xxx.cn
[web02]
type = http
local_port = 8082
custom_domains = frp3.xxx.cn
[web03]
type = http
local_port = 8083
custom_domains = frp4.xxx.cn
nginx配置转发,这样的话就可以不需要再域名后面加端口号了。
server {
listen 80;
server_name frp3.xxx.cn;
location / {
proxy_pass http://frp3.xxx.cn:10002;
}
}
server {
listen 80;
server_name frp4.xxx.cn;
location / {
proxy_pass http://frp4.xxx.cn:10002;
}
}
server {
listen 80;
server_name frp5.xxx.cn;
location / {
proxy_pass http://frp5.xxx.cn:10002;
}
}
本文链接:https://www.kinber.cn/post/1906.html 转载需授权!
推荐本站淘宝优惠价购买喜欢的宝贝: