frp 是一个专注于内网穿透的高性能的反向代理应用,通过在具有公网 IP 的节点上部署 frp 服务端,可以轻松地将内网服务穿透到公网,支持 TCP、UDP、HTTP、HTTPS 等多种协议。
项目地址:https://github.com/fatedier/frp

启动软件

服务端:./frps -c ./frps.ini
客户端:./frpc -c ./frpc.ini

服务端常用配置

[common]
bind_port = 7000
bind_udp_prot = 7000
token = abcdefg
vhost_http_port = 80
vhost_https_port = 443

# 主域名
subdomain_host = domain.com

# 仪表盘
dashboard_port = 7001
dashboard_user = admin
dashboard_pwd = admin

# 日志
log_file = /var/log/frps/info.log
# trace, debug, info, warn, error
log_level = info
log_max_days = 5

# 自定义错误页面
custom_404_page = /usr/local/etc/frps/404.html

客户端常用配置

#基础配置
[common]
server_addr = 192.168.1.1
server_port = 7000
user = user
#管理UI
admin_addr = 0.0.0.0
admin_port = 7400
admin_user = user
admin_pwd = password
#http协议
[frp_web]
type = http
local_ip = 127.0.0.1
local_port = 7400
subdomain = web
#tcp协议
[frp_tcp]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 22
#plugin
[socks5_proxy]
type = tcp
remote_port = 1080
plugin = socks5
plugin_user = username
plugin_passwd = password
#文件
[static_file]
type = tcp
remote_port = 7788
plugin = static_file
# 要对外暴露的文件目录
plugin_local_path = /Volumes/LocalDisk/
plugin_strip_prefix = static
plugin_http_user = username
plugin_http_passwd = password

配置服务端systemd

vi /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/local/bin/frps -c /usr/local/etc/frps/frps.ini

[Install]
WantedBy=multi-user.target

配置客户端systemd

vi /etc/systemd/system/frpc.service

根据自己需求修改

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

[Service]
Type=simple
User=nobody
Restart=on-failure
RestartSec=5s
ExecStart=/usr/local/bin/frpc -c /usr/local/etc/frp/frpc.ini

[Install]
WantedBy=multi-user.target

[Install]
WantedBy=multi-user.target

如果要使用管理UI修改配置文件,需要授权配置文件
chown nobody /usr/local/etc/frp/* -R