cd /usr/local/src/
wget https://github.com/fatedier/frp/releases/download/v0.37.0/frp_0.37.0_linux_amd64.tar.gz
tar -xzvf frp_0.37.0_linux_amd64.tar.gz
# 创建目录
mkdir /usr/local/frp/
# 仅复制目录的内容,而不复制目录本身,请在源目录名称的末尾附加 /.
cp -r /usr/local/src/frp_0.37.0_linux_amd64/. /usr/local/frp/
其中frpc 开头的是客户端(client) 的核心文件;其中frps 开头的是服务器端(server) 的核心文件
vim /usr/local/frp/frps.ini
[common]
#服务端绑定的端口
bind_port = 9890
#协商令牌,客户端和服务器需要一致才可以生效
token = 123456789
#仪表盘访问的端口
dashboard_port = 9891
# 仪表盘账号
dashboard_user = admin
# 仪表盘密码
dashboard_pwd = admin
vim /usr/lib/systemd/system/frps.service
[Unit]
Description=frps
After=network.target
[Service]
Type=forking
# 启动frps的命令,需修改为您的frps的安装路径
ExecStart = /usr/local/frp/frps -c /usr/local/frp/frps.ini
Restart=always
RestartSec=5
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl daemon-reload //使能服务生效
systemctl enable frps //配置开机自启
systemctl start frps //启动服务
systemctl status frps //查看服务状态
systemctl stop frps //关闭服务
vim /usr/local/frp/frpc.ini
[common]
# 服务器IP
server_addr = 100.101.102.103
#服务端绑定的端口
server_port = 9899
#协商令牌,客户端和服务器需要一致才可以生效
token = 123456789
[code]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 19122
# gogs代码
[gogs]
type = tcp
local_ip = 127.0.0.1
#本地3000端口
local_port = 3000
#映射到公网服务端对应的端口,服务端需开启防火墙
remote_port = 13000
vim /usr/lib/systemd/system/frpc.service
[Unit]
Description=frpc
After=network.target
[Service]
Type=forking
# 启动frps的命令,需修改为您的frps的安装路径
ExecStart = /usr/local/frp/frpc -c /usr/local/frp/frpc.ini
Restart=always
RestartSec=5
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl daemon-reload //使能服务生效
systemctl enable frpc //配置开机自启
systemctl start frpc //启动服务
systemctl status frpc //查看服务状态
systemctl stop frpc //关闭服务
nginx.conf
server {
listen 80;
server_name aaaaa.bbbbb.com;
access_log /data/wwwlogs/aaaaa.bbbbb.com_nginx.log combined;
index index.html index.htm index.php;
location / {
proxy_pass http://127.0.0.1:13000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $remote_addr;
}
}
访问域名 :http://aaaaa.bbbbb.com