frp 简易教程: Windows下 内网穿透 实现外网使用远程桌面连接,代理web服务。

 

frp项目地址:fatedier/frp: A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet. (github.com)

 

服务器端配置:frps.ini 文件

[common]

bind_port = 7200  #基本端口 程序运行需要

vhost_http_port = 8200 #http使用端口

# auth token
# token = 12345678
dashboard_port = 7500 #控制面板访问端口

# dashboard user and passwd for basic auth protect
dashboard_user = userName
dashboard_pwd = 123654789 

 

 

客户端配置: frpc.ini 文件

[common]
server_addr = 你的服务端地址
server_port = 7200 # frp服务器端运行端口 必填
# auth token
# token = 12345678

#远程桌面配置
[RDP]
type = tcp
local_ip = 127.0.0.1
local_port = 3389 #本地 微软远程桌面默认使用端口
remote_port = 6600 #服务器代理端口


#web服务代理配置
[webapi]
type = http
local_ip = 127.0.0.1
local_port = 8080 #本地web服务访问端口
remote_port = 8200  #服务器代理端口
custom_domains =  你的服务端IP地址
#为了兼容mqtt客户端连接 不使用域名了
 

 注意:以上配置文件中在实际使用的时候 需要把#注释内容去掉,否则frp会读取配置文件异常,导致异常报错

 

frp配置自启动 ,windows  service 服务封装:

项目地址:winsw/winsw: A wrapper executable that can run any executable as a Windows service, in a permissive license. (github.com)

使用步骤:

1:新建/编辑 winsw.xml配置文件

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

2:执行对应命令:

//注册服务
winsw.exe install
//卸载服务
winsw.exe uninstall
//启动服务
winsw.exe start
//停止服务
winsw.exe stop
//重启服务
winsw.exe restart
//查看状态
winsw.exe status

cd到程序目录 执行命令安装。

 注意:frp程序放置的目录路径中不要包含带空格符合的,否则执行winsw命令是导致异常报错 (Error: unknown command "Files\\frpc\\frpc.ini" for "frpc"

 

 

效果:

 

posted @ 2022-05-09 13:46  rhyswang  阅读(1486)  评论(0编辑  收藏  举报