Frp的使用指南

简介

frp 是一个专注于内网穿透的高性能的反向代理应用,支持 TCP、UDP、HTTP、HTTPS 等多种协议。可以将内网服务以安全、便捷的方式通过具有公网 IP 节点的中转暴露到公网。Frp分为服务端和客户端。

Github : https://github.com/fatedier/frp

中文文档:https://gofrp.org/docs/

Frp Server 服务端

配置文件

复制配置文件请务必删掉注释

服务端参数说明请移步:https://gofrp.org/docs/reference/server-configures/

[common]
bind_port = 9998 #服务端需要开启的端口(与客户端绑定的进行通信的端口)
dashboard_port = 1080 #frps仪表盘绑定端口

token=hcw022703.. #鉴权token
dashboard_user=qifengg #仪表盘账号
dashboard_pwd=Hcw022703.. #仪表盘密码
vhost_http_port=9999 #服务端需要开启的端口(访问客户端web服务自定义的端口号)
#vhost_https_port = 10443 # https端口

命令

liunx

nohup
chomod 777 frps #赋权限
./frps -c ./frps.ini #使用目录下的frps.ini 配置尝试启动 Ctrl+C 退出
nohup ./frps -c ./frps.ini & #使用nohup后台运行frps 目录下nohup.txt有日志
killall -9 frps #杀掉正在后台运行的frps
service

Systemd.Service 中文手册

#服务内容
[Unit]
Description=frps
After=network.target

[Service]
Restart=on-failure
RestartSec=5 
ExecStart=/root/frp/frps -c /root/frp/frps.ini #注意 这里frps的路径 和 frps.ini 路径要正确

[Install]
WantedBy=multi-user.target
#

## 一般出错都是在(frps或frpc)启动程序的路径和(frps.ini或frpc.ini)文件路径不对,导致服务开启失败。
sudo vim /usr/lib/systemd/system/frps.service #创建frps服务文件
sudo systemctl enable frps #启用frps服务
sudo systemctl start frps #启动frps服务
sudo systemctl list-units |grep frps  #查看frps服务是否生效 显示frps.service loaded active running 就表示服务开启成功
sudo systemctl status frps #查看服务日志
sudo systemctl restart frps #重启frps服务

windows

winsw Githuh项目地址

常用命令

winsw.exe install ##安装服务
winsw.exe uninstall ##卸载服务
winsw.exe start ##启动服务
winsw.exe stop ##停止服务
winsw.exe restart ##重启服务
winsw.exe status ##检查服务的状态
winsw.exe refresh ## 刷新服务属性

配置文件

<service>
<!-- 该服务的唯一标识 -->
    <id>frps</id>
    <!-- 该服务的名称 -->
    <name>frp server</name>
    <!-- 该服务的描述 -->
    <description>frp服务端 用来作为内网穿透的跳板</description>
    <!-- 要运行的程序路径 -->
    <executable>./frps.exe</executable>
    <!-- 携带的参数 -->
    <arguments>-c frps.ini</arguments>
    <!-- 第一次启动失败 60秒重启 -->
    <onfailure action="restart" delay="60 sec"/>
    <!-- 第二次启动失败 120秒后重启 -->
    <onfailure action="restart" delay="120 sec"/>
    <!-- 日志模式 -->
    <logmode>append</logmode>
    <!-- 指定日志文件目录(相对于executable配置的路径) -->
    <logpath>service-logs</logpath>
</service>
#Frpc
chomod 777 frpc #赋权限
./frpc -c ./frpc.ini #使用目录下的frpc.ini 配置尝试启动 Ctrl+C 退出
nohup ./frpc -c ./frpc.ini & #使用nohup后台运行frpc 目录下nohup.txt有日志
killall -9 frpc #杀掉正在后台运行的frpc

Frp Client 客户端

配置文件

复制配置文件请务必删掉注释

客户端参数说明请移步:https://gofrp.org/docs/reference/client-configures/

客户端插件说明请移步:https://gofrp.org/docs/features/common/client-plugin/

[common]
server_addr = frp.qifengg.xyz #Frps的服务器地址 可以是域名可以是ip
server_port = 9998 #Frps的端口
token = hcw022703..  #Frps的token

[kuade-linux_ssh] #自定义名称 frps后台可以查看
type = tcp
local_ip = 192.168.150.105 #本地ip
local_port = 22 #本地端口
remote_port = 23 #远程地址

[kuade-xuexi_web] #自定义名称 frps后台可以查看
type = http
local_port = 2703
remote_port=9980
custom_domains = xx.qifengg.xyz #自定义的域名

[kuade-docker_web]
type = http
local_port = 9000
remote_port=16660
custom_domains = frp.qifengg.xyz

命令

Liunx

nohup
chomod 777 frpc #赋权限
./frpc -c ./frpc.ini #使用目录下的frpc.ini 配置尝试启动 Ctrl+C 退出
nohup ./frpc -c ./frpc.ini & #使用nohup后台运行frpc 目录下nohup.txt有日志
killall -9 frpc #杀掉正在后台运行的frpc
service

Systemd.Service 中文手册

#服务内容
[Unit]
Description=frpc
After=network.target

[Service]
Restart=on-failure
RestartSec=5
ExecStart=/root/frp/frpc -c /root/frp/frpc.ini #注意 这里frpc的路径 和 frpc.ini 路径要正确

[Install]
WantedBy=multi-user.target
#

## 一般出错都是在(frps或frpc)启动程序的路径和(frps.ini或frpc.ini)文件路径不对,导致服务开启失败。
sudo vim /usr/lib/systemd/system/frpc.service #创建frpc服务文件
sudo systemctl enable frpc #启用frps服务
sudo systemctl start frpc #启动frpc服务
sudo systemctl list-units |grep frps  #查看frps服务是否生效 显示frps.service loaded active running 就表示服务开启成功
sudo systemctl status frpc #查看服务日志
sudo systemctl restart frpc #重启frpc服务

windows

winsw Githuh项目地址

命令

winsw.exe install ##安装服务
winsw.exe uninstall ##卸载服务
winsw.exe start ##启动服务
winsw.exe stop ##停止服务
winsw.exe restart ##重启服务
winsw.exe status ##检查服务的状态
winsw.exe refresh ## 刷新服务属性

配置文件

<service>
<!-- 该服务的唯一标识 -->
    <id>frpc</id>
    <!-- 该服务的名称 -->
    <name>frp client</name>
    <!-- 该服务的描述 -->
    <description>frp客户端 内网穿透</description>
    <!-- 要运行的程序路径 -->
    <executable>./frpc.exe</executable>
    <!-- 携带的参数 -->
    <arguments>-c frpc.ini</arguments>
    <!-- 第一次启动失败 60秒重启 -->
    <onfailure action="restart" delay="60 sec"/>
    <!-- 第二次启动失败 120秒后重启 -->
    <onfailure action="restart" delay="120 sec"/>
    <!-- 日志模式 -->
    <logmode>append</logmode>
    <!-- 指定日志文件目录(相对于executable配置的路径) -->
    <logpath>service-logs</logpath>
</service>