centos+frp
https://zhuanlan.zhihu.com/p/129076009
https://www.jianshu.com/p/93bf511ea72e
https://www.cnblogs.com/L-ran/p/12082670.html
wget https://github.com/fatedier/frp/releases/download/v0.35.1/frp_0.35.1_linux_amd64.tar.gz
tar -xvf frp_0.35.1_linux_amd64.tar.gz
mkdir /usr/local/frp
mv frp_0.35.1_linux_amd64/* /usr/local/frp/
服务器端:
cd /usr/local/frp/
rm frpc*
vim frps.ini
[common] 必须设置
bind_port 是自己设定的frp服务端端口
vhost_http_port 是自己设定的http访问端口
[ssh] ssh 反向代理(不是必须设置)
listen_port 是自己设定的ssh访问端口
auth_token 用于身份认证(以下皆是)。
[web] http反向代理[]里的内容可以自己设定,但是客户端和服务端必须要对应(如[aaa],[bbb]);
type 为服务类型,可以设为http,https
custom_domains 为要映射的域名,记得域名的A记录要解析到外网主机的IP。
[web2] 同上(可设置多个)
[common]
bind_port = 7000
vhost_http_port = 80
[ssh]
listen_port = 6000
auth_token = 123
[web]
type = http
custom_domains = test1.a.com
auth_token = 123
[web2]
type = http
custom_domains = test2.a.com
auth_token = 123
实际上使用以下,同网上不一样:
[root@vmcentos7 frp]# cat /usr/local/frp/frps.ini
[common]
bind_port = 7000
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/frps -c /usr/local/frp/frps.ini
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
StandardOutput=syslog
StandardError=inherit
[Install]
WantedBy=multi-user.target
客户端:
cd /usr/local/frp/
rm frps*
vim frpc.ini
[common]必填 server_addr frp服务端的ip(也就是外网主机的IP) server_port frp服务端的bind_prot。 [ssh] local_port 客户端ssh端口。 [web] type 对应服务端配置 local_port 客户端访问端口。 [web2]同上
[common]
server_addr = 10.10.10.10
server_port = 7000
auth_token = 123
[ssh]
local_port = 22
[web]
type = http
local_port = 80
[web2]
type = http
local_port = 8080
[common]
server_addr = x.x.x.x
server_port = 7000
[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000
[nas]
type = http
local_port = 5000
custom_domains = no1.sunnyrx.com
[web]
type = http
local_port = 80
custom_domains = no2.sunnyrx.com
实际上使用:
[root@vmcentos7-1 ~]# cat /usr/local/frp/frpc.ini
[common]
server_addr = 8.8.8.8
server_port = 7000
[ssh]
type = tcp
local_ip = 9.9.9.9
local_port = 22
remote_port = 6000
[nginx]
type = tcp
local_ip = 9.9.9.9
local_port = 80
remote_port = 6001
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/frpc -c /usr/local/frp/frpc.ini
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
StandardOutput=syslog
StandardError=inherit
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start frp systemctl stop frp systemctl restart frp systemctl status frp systemctl enable frp systemctl disable frp
/usr/local/frp/frps -c /usr/local/frp/frps.ini
/usr/local/frp/frpc -c /usr/local/frp/frpc.ini