受欢迎的博客标签

FRP v0.65.0 内网穿透专业指南(SSH + HTTP/HTTPS 一体化配置)

Published

FRP v0.65.0 内网穿透专业指南(SSH + HTTP/HTTPS 一体化配置)

 

架构

  • 服务端(frps):部署在公网服务器上,监听 TCP(默认 7000)和 HTTP/HTTPS vhost 端口(默认 80/443)。

  • 客户端 (frpc):运行在内网主机或 WSL,建立持久 TCP 长连接到 frps。

  • 穿透原理:frps 接收公网请求,通过长连接转发到对应 frpc,再由 frpc 访问本地服务,响应回传给公网。

  •  


服务端安装与配置

下载与安装

wget https://github.com/fatedier/frp/releases/download/v0.65.0/frp_0.65.0_linux_amd64.tar.gz
tar -zxvf frp_0.65.0_linux_amd64.tar.gz
sudo mv frp_0.65.0_linux_amd64/* /usr/local/frp
cd /usr/local/frp

frps.toml 示例

bindPort = 7000
token = "REPLACE_WITH_SECURE_TOKEN"

vhostHTTPPort = 80
vhostHTTPSPort = 443


auth.method = "token"
auth.token = "REPLACE_WITH_SECURE_TOKEN"

logFile = "./frps.log"
logLevel = "info"
logMaxDays = 3

systemd 启动服务

/etc/systemd/system/frps.service:

[Unit]
Description=frps - fast reverse proxy server
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/usr/local/frp
ExecStart=/usr/local/frp/frps -c /usr/local/frp/frps.toml
Restart=on-failure
RestartSec=5s
LimitNOFILE=1048576

[Install]
WantedBy=multi-user.target
 
 
sudo systemctl daemon-reload 
sudo systemctl enable  frps

 

 

客户端配置(SSH + HTTP + HTTPS)

下载与安装

wget https://github.com/fatedier/frp/releases/download/v0.65.0/frp_0.65.0_linux_arm64.tar.gz
tar -zxvf frp_0.65.0_linux_arm64.tar.gz
sudo mv frp_0.65.0_linux_arm64/* /usr/local/frp
cd /usr/local/frp

 

 frpc.toml:

serverAddr = "YOUR_FRPS_IP_OR_DOMAIN"
serverPort = 7000

auth.method = "token"
auth.token = "REPLACE_WITH_SECURE_TOKEN"

# HTTP 内网穿透
[[proxies]]
name = "main-http"
type = "http"
localIP = "127.0.0.1"
localPort = 3000
customDomains = ["huaxianguan.com"]

# HTTP 内网穿透
[[proxies]]
name = "main-http"
type = "http"
localIP = "127.0.0.1"
localPort = 3100
customDomains = ["a.huaxianguan.com"]

client systemd

/etc/systemd/system/frpc.service

 

[Unit]
Description=frpc - FRP client
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/usr/local/frp
ExecStart=/usr/local/frp/frpc -c /etc/frp/frpc.toml
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
 
systemd 启动客户端服务
sudo systemctl daemon-reload 
sudo systemctl enable  frpc

 

configuration

https://github.com/fatedier/frp/blob/dev/conf/frps_full_example.toml

https://github.com/fatedier/frp/blob/dev/conf/frpc_full_example.toml

 

useful links

https://jishuzhan.net/article/1975084914518327298