这一次,我们重新定义智慧互联网

微信号:foreverbestvip

详细了解

每一次尝试都代表着时代的进步

微信号:foreverbestvip

详细了解

这一刻,我们都是世界的佼佼者

微信号:foreverbestvip

详细了解

智慧互联网产品开发的领航者

微信号:foreverbestvip

详细了解

Ubuntu配置Frp内网穿透

免费 - Sunrise - - 浏览量: 0 - 文章来源

服务文件

服务端: vim /usr/lib/systemd/system/frps.service

客户端: vim /usr/lib/systemd/system/frpc.service

客户端穿透配置

[common]
server_addr = xxx.xxx.xxx.xxx
server_port = 7000
token = xxxxx
pool_count = 5
log_file = /var/log/frps.log

[ssh]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 6000

[web]
type = http
local_port = 80
vhost_http_port = 8888
subdomain = dev

客户端服务配置

[Unit]
Description=Frp Client Service
After=network.target

[Service]
Type=simple
User=root
Restart=on-failure
ExecStart=/usr/local/frp/frpc -c /usr/local/frp/frpc.ini
ExecReload=/usr/local/frp/frpc -c /usr/local/frp/frpc.ini
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
StandardOutput=syslog
StandardError=inherit
RestartSec=5s

[Install]
WantedBy=multi-user.target

服务端穿透配置

[common]
bind_addr = 0.0.0.0
bind_port = 7000
vhost_http_port = 8888
subdomain_host = example.com
dashboard_addr = 0.0.0.0
dashboard_port = 8000
dashboard_user = admin
dashboard_pwd = xxxxx
log_file = /var/log/frps.log
token = xxxxx

服务端服务配置

[Unit]
Description=Frp Server Service
After=network.target

[Service]
Type=simple
User=root
Restart=on-failure
ExecStart=/usr/local/frp/frps -c /usr/local/frp/frps.ini
ExecReload=/usr/local/frp/frps -c /usr/local/frp/frps.ini
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
StandardOutput=syslog
StandardError=inherit
RestartSec=5s

[Install]
WantedBy=multi-user.target

系统命令

#重新加载服务列表
systemctl daemon-reload

#将frps加入开机自启动
systemctl enable frps.service

#启动服务
systemctl start frps.service

#关闭服务
systemctl stop frps.service

#重启服务
systemctl restart frps.service

#显示服务的状态
systemctl status frps.service

#禁用服务开机启动
systemctl disable frps.service

#查看服务是否开机启动
systemctl is-enabled frps.service

#查看已经启动的服务列表
systemctl list-unit-files|grep enable

#查看启动失败的服务列表
systemctl --failed

服务端nginx配置域名不带端口号访问dev.example.com

server {
     listen 80;
     listen [::]:80;
     server_name dev.example.com;

     location / {
        proxy_pass http://127.0.0.1:8888;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_hide_header X-Powered-By;
        allow xxx.xxx.xxx.xxx; # 指定ip可以访问
        deny all;
     }
}

谈谈你的看法

请文明发言!