FRP 反向代理,穿透你的家庭公网
What is frp?
rp is a fast reverse proxy to help you expose a local server behind a NAT or firewall to the Internet. As of now, it supports TCP and UDP, as well as HTTP and HTTPS protocols, where requests can be forwarded to internal services by domain name.
frp also has a P2P connect mode.
架构
FRP分为服务端frps
和客户端frpc
。架构如下:
设置服务端systemd service, /etc/systemd/system/frps.service
:
[Unit]
Description=Frp Server Service
After=network.target
[Service]
Type=simple
User=nobody
Restart=on-failure
RestartSec=5s
ExecStart=/usr/bin/frps -c /etc/frp/frps.ini
LimitNOFILE=1048576
[Install]
WantedBy=multi-user.target
服务端设置好后:
Congratulations, frps install completed!
==============================================
You Server IP : 123.123.123.123
Bind port : 7020
Dashboard port : 7500
vhost http port : 7080
vhost https port: 7443
Privilege token : tokenxxxxx!
Max Pool count : 50
Log level : info
Log max days : 3
Log file : enable
客户端 frpc.ini
:
[common]
server_addr = 123.123.123.123
server_port = 7020
[web]
type = http
local_port = 80
custom_domains = frp.domain.com
nginx 代理:
server {
# 监听nginx 80端口
listen 80;
# 域名配置 记得一定要加上*.frp.xxx.com + frp.xxx.com这个,只加frp.xxx.com是不行的,无法支持泛域名做sub模式
server_name *.frp.xxx.com frp.xxx.com;
location / {
proxy_pass http: //127.0.0.1:7001;
# 这个Host的header一定要加,不然转发后frp拿不到通过哪个域名访问的,导致转发失败
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
评论已关闭