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 = 7080
vhost_https_port = 7443

# 主域名
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

admin_addr = 0.0.0.0
admin_port = 7400
admin_user = dcb
admin_pwd = hIyFb4r4gNmhrC23

[frp_web]
type = http
local_ip = 127.0.0.1
local_port = 7400
subdomain = web

[frp_tcp]
type = tcp
local_ip = 127.0.0.1
local_port = 22
remote_port = 22

[socks5_proxy]
type = tcp
remote_port = 7777
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