前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >frp 供内网穿透服务的工具

frp 供内网穿透服务的工具

作者头像
Tinywan
发布2019-07-16 12:58:46
1.6K0
发布2019-07-16 12:58:46
举报
文章被收录于专栏:开源技术小栈
frp 供内网穿透服务的工具

项目地址: https://github.com/fatedier/frp

修改配置文件:

代码语言:javascript
复制
 1[common]
 2server_addr = frp.yo1c.cc
 3server_port = 7000
 4#log_file = ./frpc.log
 5log_level = info
 6log_max_days = 3
 7privilege_token = 30064E394C1C63766DA345EEFDA490EF
 8
 9[pay]
10type = http
11local_ip = 127.0.0.1
12local_port = 80
13subdomain = tinywan 
14#custom_domains = www.yourdomain.com
15pool_count = 10

使用git shell 启动服务

代码语言:javascript
复制
1// 进入到当前frp文件目录
2$ ./frpc.exe -c ./frpc.ini
32018/07/09 18:05:44 [I] [control.go:276] [61198354d3f13b48] login to server success, get run id [61198354d3f13b48]
42018/07/09 18:05:45 [I] [control.go:411] [61198354d3f13b48] [pay] start proxy success

phpstudy 配置vhost

代码语言:javascript
复制
 1<VirtualHost *:80>
 2    DocumentRoot "D:\phpStudy\PHPTutorial\WWW\pay_project_dev\public"
 3    ServerName pay.env
 4    ServerAlias frp.tinywan.top
 5  <Directory "D:\phpStudy\PHPTutorial\WWW\pay_project_dev\public">
 6      Options FollowSymLinks ExecCGI
 7      AllowOverride All
 8      Order allow,deny
 9      Allow from all
10     Require all granted
11  </Directory>
12</VirtualHost>

重启phpstudy服务

访问公网地址:http://frp.tinywan.top/?aa=bb,可以方便调试异步回调

提示错误信息

frp安装的时候,提示:login to server failed: EOF

代码语言:javascript
复制
1$ ./frpc.exe -c frpc.ini
22018/07/20 09:28:22 [W] [control.go:121] login to server failed: broken pipe
3broken pipe

这种情况是客户端版本和服务器版本的版本号不一致


配置一个域名

服务端配置
代码语言:javascript
复制
1[common]
2bind_port = 7000
3vhost_http_port = 8080

IP:139.224.239.21 域名 frp.tinywan.top 已经被A记录到139.224.239.21

客户端配置
代码语言:javascript
复制
1[common]
2server_addr = 139.224.239.21 # 可以直接换成 www.tinywan.com
3server_port = 7000
4
5[web]
6type = http
7local_port = 80
8custom_domains = frp.tinywan.top
phpStudy配置 `vhosts.conf`
代码语言:javascript
复制
 1<VirtualHost *:80>
 2    DocumentRoot "D:\phpStudy\PHPTutorial\WWW\notes\public"
 3    ServerName notes.env   // 本地访问域名
 4    ServerAlias frp.tinywan.top // 外网访问域名
 5  <Directory "D:\phpStudy\PHPTutorial\WWW\notes\public">
 6      Options FollowSymLinks ExecCGI
 7      AllowOverride All
 8      Order allow,deny
 9      Allow from all
10     Require all granted
11  </Directory>
12</VirtualHost>

浏览器地址栏:http://frp.tinywan.top:8080/index/index/last_insert_id

将会通过外网访问本地Web项目了

自定义二级域名

服务端配置
代码语言:javascript
复制
1[common]
2bind_port = 7000
3vhost_http_port = 8007
4subdomain_host = tinywan.top
5token = 2W/WktjD1QB9xX/oDZSnH8mv81xzLNU283ern8YiFtY=

服务端IP:139.224.239.21 阿里云域名解析: *.tinywan.top A记录到139.224.239.21

客户端配置
  • 配置一(我的PC配置) <br />[notes]<br />type = http<br />local_ip = 127.0.0.1<br />local_port = 80<br />use_encryption = false<br />use_compression = false<br />subdomain = notes<br />
  • 配置二(我的笔记本配置) <br />[pay]<br />type = http<br />local_ip = 127.0.0.1<br />local_port = 80<br />use_encryption = false<br />use_compression = false<br />subdomain = pay<br />
phpStudy配置 `vhosts.conf`

PC配置

代码语言:javascript
复制
 1<VirtualHost *:80>
 2    DocumentRoot "D:\phpStudy\PHPTutorial\WWW\notes\public"
 3    ServerName notes.env
 4    ServerAlias notes.tinywan.top
 5  <Directory "D:\phpStudy\PHPTutorial\WWW\notes\public">
 6      Options FollowSymLinks ExecCGI
 7      AllowOverride All
 8      Order allow,deny
 9      Allow from all
10     Require all granted
11  </Directory>
12</VirtualHost>

笔记本配置

代码语言:javascript
复制
 1<VirtualHost *:80>
 2    DocumentRoot "D:\phpStudy\PHPTutorial\WWW\pay_project_dev\public"
 3    ServerName pay.env
 4    ServerAlias pay.tinywan.top
 5  <Directory "D:\phpStudy\PHPTutorial\WWW\pay_project_dev\public">
 6      Options FollowSymLinks ExecCGI
 7      AllowOverride All
 8      Order allow,deny
 9      Allow from all
10     Require all granted
11  </Directory>
12</VirtualHost>
访问浏览器
  • 地址一:http://notes.tinywan.top:8007/index/index/last_insert_id
  • 地址二:http://pay.tinywan.top:8007/index/index/last_insert_id

自定义三级域名

【1】二级域名:*.frp.tinywan.top 域名解析A记录到:139.224.239.21 【2】服务端配置:subdomain_host = frp.tinywan.top 【3】客户端配置:

代码语言:javascript
复制
1[notes]
2type = http
3local_ip = 127.0.0.1
4local_port = 80
5use_encryption = false
6use_compression = false
7subdomain = notes

【4】phpStudy配置 vhosts.confServerAlias notes.frp.tinywan.top 【5】浏览器访问:http://notes.frp.tinywan.top:8007 即可访问 【6】Nginx做一个反向代理

代码语言:javascript
复制
 1server {
 2    server_name  notes.frp.tinywan.top;
 3
 4    location / {
 5        proxy_pass http://0.0.0.0:8007;
 6
 7        #Proxy Settings
 8        proxy_set_header   Host             $host;
 9        proxy_set_header   X-Real-IP        $remote_addr;
10        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
11    }
12}

通过:http://notes.frp.tinywan.top 即可访问

配置多个客户端

这里配置多个客户端,只要开启本地WEB服务就可以直接访问了

多客户端配置

代码语言:javascript
复制
 1[notes]
 2type = http
 3local_ip = 127.0.0.1
 4local_port = 80
 5use_encryption = false
 6use_compression = false
 7subdomain = notes
 8
 9[pay]
10type = http
11local_ip = 127.0.0.1
12local_port = 80
13use_encryption = false
14use_compression = false
15subdomain = pay

vhost.conf配置

代码语言:javascript
复制
 1<VirtualHost *:80>
 2    DocumentRoot "D:\phpStudy\PHPTutorial\WWW\notes\public"
 3    ServerName notes.env
 4    ServerAlias notes.frp.tinywan.top
 5    ...
 6</VirtualHost>
 7
 8
 9<VirtualHost *:80>
10    DocumentRoot "D:\phpStudy\PHPTutorial\WWW\pay_project_dev\public"
11    ServerName pay.env
12    ServerAlias pay.frp.tinywan.top
13    ...
14</VirtualHost>
Nginx 配置

直接做两个代理皆可以

配置一:proxy_local:8007-notes.frp.tinywan.top.conf

代码语言:javascript
复制
 1server {
 2    server_name  notes.frp.tinywan.top;
 3
 4    location / {
 5        proxy_pass http://0.0.0.0:8007;
 6        proxy_set_header   Host             $host;
 7        proxy_set_header   X-Real-IP        $remote_addr;
 8        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
 9    }
10}

配置二:proxy_local:8007-pay.frp.tinywan.top.conf

代码语言:javascript
复制
 1server {
 2    server_name  pay.frp.tinywan.top;
 3
 4    location / {
 5        proxy_pass http://0.0.0.0:8007;
 6        proxy_set_header   Host             $host;
 7        proxy_set_header   X-Real-IP        $remote_addr;
 8        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
 9    }
10}

Windows 批处理文件 start_service.bat

代码语言:javascript
复制
1frpc.exe -c frpc.ini
2pause
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2018-12-27,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Tinywan的杂货摊 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 提示错误信息
  • 配置一个域名
    • 服务端配置
      • 客户端配置
        • phpStudy配置 `vhosts.conf`
        • 自定义二级域名
        • 自定义三级域名
        • 配置多个客户端
          • Nginx 配置
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档