frp 内网穿透工具 frp

xuanbao2016-09-07 15:56:33 • 24201 次点击    
这是一个分享于 2016-09-07 15:56:33 的项目,其中的信息可能已经有所发展或是发生改变。

frp 是一个高性能的反向代理应用,可以帮助您轻松地进行内网穿透,对外网提供服务,支持 tcp, http, https 等协议类型,并且 web 服务支持根据域名进行路由转发。

### frp 的作用

*

        利用处于内网或防火墙后的机器,对外网环境提供 http 或 https 服务。

*

        对于 http 服务支持基于域名的虚拟主机,支持自定义域名绑定,使多个域名可以共用一个80端口。

*

        利用处于内网或防火墙后的机器,对外网环境提供 tcp 服务,例如在家里通过 ssh 访问处于公司内网环境内的主机。

*

        可查看通过代理的所有 http 请求和响应的详细信息。(待开发)

### 开发状态

frp 目前正在前期开发阶段,master 分支用于发布稳定版本,dev 分支用于开发,您可以尝试下载最新的 release 版本进行测试。

目前的交互协议可能随时改变,不能保证向后兼容,升级新版本时需要注意公告说明。

### 架构

image

### 使用示例

    根据对应的操作系统及架构,从 [Release](https://github.com/fatedier/frp/releases) 页面下载最新版本的程序。


    将 frps 及 frps.ini 放到有公网 IP 的机器上。


    将 frpc 及 frpc.ini 放到处于内网环境的机器上。

### 通过 ssh 访问公司内网机器

  1. 修改 frps.ini 文件,配置一个名为 ssh 的反向代理:

    frps.ini

    [common] bind_port = 7000

[ssh] listen_port = 6000 auth_token = 123

2.

        启动 frps:

./frps -c ./frps.ini

3.

        修改 frpc.ini 文件,设置 frps 所在服务器的 IP 为 x.x.x.x:

frpc.ini

[common] server_addr = x.x.x.x server_port = 7000 auth_token = 123

[ssh] local_port = 22

4.

        启动 frpc:

./frpc -c ./frpc.ini

5.

        通过 ssh 访问内网机器,假设用户名为 test:

ssh -oPort=6000 test@x.x.x.x

### 通过指定域名访问部署于内网的 web 服务

有时想要让其他人通过域名访问或者测试我们在本地搭建的 web 服务,但是由于本地机器没有公网 IP,无法将域名解析到本地的机器,通过 frp 就可以实现这一功能,以下示例为 http 服务,https 服务配置方法相同, vhost_http_port 替换为 vhost_https_port, type 设置为 https 即可。

1.

        修改 frps.ini 文件,配置一个名为 web 的 http 反向代理,设置 http 访问端口为 8080,绑定自定义域名 www.yourdomain.com:

# frps.ini

[common] bind_port = 7000 vhost_http_port = 8080

[web] type = http custom_domains = www.yourdomain.com auth_token = 123

2.

        启动 frps;

./frps -c ./frps.ini

3.

        修改 frpc.ini 文件,设置 frps 所在的服务器的 IP 为 x.x.x.x,local_port 为本地机器上 web 服务对应的端口:

frpc.ini

[common] server_addr = x.x.x.x server_port = 7000 auth_token = 123

[web] type = http local_port = 80

4.

         启动 frpc:

./frpc -c ./frpc.ini

5.

         将 [www.yourdomain.com](http://www.yourdomain.com/) 的域名 A 记录解析到 x.x.x.x,如果服务器已经有对应的域名,也可以将 CNAME 记录解析到服务器原先的域名。

6.

        通过浏览器访问 http://www.yourdomain.com:8080 即可访问到处于内网机器上的 web 服务。

### 开发计划

计划在后续版本中加入的功能与优化,排名不分先后,如果有其他功能建议欢迎在 issues 中反馈。

*

        Dashboard 界面。

*

        流量,连接数等代理信息统计与展示。

*

        udp 协议支持。

*

        针对短连接的连接池优化。

*

        特权模式支持端口白名单。

*

        支持泛域名。

*

        支持 url 路由转发。

*

        frpc 支持负载均衡到后端不同服务。

*

        frpc debug 模式,控制台显示代理状态,类似 ngrok 启动后的界面。

*

        frpc http 请求及响应信息展示。

*

        支持 udp 打洞的方式,提供两边内网机器直接通信,流量不经过服务器转发。
./frps -c ./frps.ini
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
auth_token = 123

[ssh]
local_port = 22
./frpc -c ./frpc.ini
ssh -oPort=6000 test@x.x.x.x
# frps.ini
[common] bind_port = 7000
vhost_http_port = 8080

[web]
type = http
custom_domains = www.yourdomain.com
auth_token = 123
./frps -c ./frps.ini
# frpc.ini
[common]
server_addr = x.x.x.x
server_port = 7000
auth_token = 123

[web]
type = http
local_port = 80
 ./frpc -c ./frpc.ini

A fast reverse proxy to help you expose a local server behind a NAT or firewall to the internet.Read More

Latest commit to the dev branch on 4-8-2025
Download as zip
授权协议:
GPL
开发语言:
Google Go 查看源码»
操作系统:
跨平台
24201 次点击  
加入收藏 微博
1 回复  |  直到
xiye518
xiye518 · #1 · 7年之前

mark 有空测试下

添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传