frp 供内网穿透服务的工具
项目地址: https:///fatedier/frp
修改配置文件:
[common]
server_addr =
server_port = 7000
#log_file = ./frpc.log
log_level = info
log_max_days = 3
privilege_token = 30064E394C1C63766DA345EEFDA490EF
[pay]
type = http
local_ip = 127.0.0.1
local_port = 80
subdomain = tinywan
#custom_domains = www.yourdomain.com
pool_count = 10
[common]
server_addr =
server_port = 7000
#log_file = ./frpc.log
log_level = info
log_max_days = 3
privilege_token = 30064E394C1C63766DA345EEFDA490EF
[pay]
type = http
local_ip = 127.0.0.1
local_port = 80
subdomain = tinywan
#custom_domains = www.yourdomain.com
pool_count = 10使用git shell 启动服务
// 进入到当前frp文件目录
$ ./frpc.exe -c ./frpc.ini
2018/07/09 18:05:44 [I] [control.go:276] [61198354d3f13b48] login to server success, get run id [61198354d3f13b48]
2018/07/09 18:05:45 [I] [control.go:411] [61198354d3f13b48] [pay] start proxy successphpstudy 配置vhost
<VirtualHost *:80>
DocumentRoot "D:\phpStudy\PHPTutorial\WWW\pay_project_dev\public"
ServerName pay.env
ServerAlias
<Directory "D:\phpStudy\PHPTutorial\WWW\pay_project_dev\public">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>重启phpstudy服务
访问公网地址:http:///?aa=bb,可以方便调试异步回调
提示错误信息
frp安装的时候,提示:login to server failed: EOF
$ ./frpc.exe -c frpc.ini
2018/07/20 09:28:22 [W] [control.go:121] login to server failed: broken pipe
broken pipe这种情况是客户端版本和服务器版本的版本号不一致
配置一个域名
服务端配置
[common]
bind_port = 7000
vhost_http_port = 8080IP:
139.224.239.21域名已经被A记录到139.224.239.21
客户端配置
[common]
server_addr = 139.224.239.21 # 可以直接换成 www.tinywan.com
server_port = 7000
[web]
type = http
local_port = 80
custom_domains = phpStudy配置 vhosts.conf
<VirtualHost *:80>
DocumentRoot "D:\phpStudy\PHPTutorial\WWW\notes\public"
ServerName notes.env // 本地访问域名
ServerAlias // 外网访问域名
<Directory "D:\phpStudy\PHPTutorial\WWW\notes\public">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>浏览器地址栏:
http://:8080/index/index/last_insert_id
将会通过外网访问本地Web项目了
自定义二级域名
服务端配置
[common]
bind_port = 7000
vhost_http_port = 8007
subdomain_host =
token = 2W/WktjD1QB9xX/oDZSnH8mv81xzLNU283ern8YiFtY=服务端IP:
139.224.239.21阿里云域名解析:*.A记录到139.224.239.21
客户端配置
- 配置一(我的PC配置)
[notes] type = http local_ip = 127.0.0.1 local_port = 80 use_encryption = false use_compression = false subdomain = notes - 配置二(我的笔记本配置)
[pay] type = http local_ip = 127.0.0.1 local_port = 80 use_encryption = false use_compression = false subdomain = pay
phpStudy配置 vhosts.conf
PC配置
<VirtualHost *:80>
DocumentRoot "D:\phpStudy\PHPTutorial\WWW\notes\public"
ServerName notes.env
ServerAlias notes.
<Directory "D:\phpStudy\PHPTutorial\WWW\notes\public">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>笔记本配置
<VirtualHost *:80>
DocumentRoot "D:\phpStudy\PHPTutorial\WWW\pay_project_dev\public"
ServerName pay.env
ServerAlias pay.
<Directory "D:\phpStudy\PHPTutorial\WWW\pay_project_dev\public">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>访问浏览器
- 地址一:
http://notes.:8007/index/index/last_insert_id - 地址二:
http://pay.:8007/index/index/last_insert_id
自定义三级域名
【1】二级域名:
*.域名解析A记录到:139.224.239.21【2】服务端配置:
subdomain_host =【3】客户端配置:
[notes]
type = http
local_ip = 127.0.0.1
local_port = 80
use_encryption = false
use_compression = false
subdomain = notes【4】phpStudy配置
vhosts.conf:ServerAlias notes.【5】浏览器访问:
http://notes.:8007即可访问【6】Nginx做一个反向代理
server {
server_name notes.;
location / {
proxy_pass http://0.0.0.0:8007;
#Proxy Settings
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}通过:
http://notes.即可访问
配置多个客户端
这里配置多个客户端,只要开启本地WEB服务就可以直接访问了
多客户端配置
[notes]
type = http
local_ip = 127.0.0.1
local_port = 80
use_encryption = false
use_compression = false
subdomain = notes
[pay]
type = http
local_ip = 127.0.0.1
local_port = 80
use_encryption = false
use_compression = false
subdomain = pay
vhost.conf配置
<VirtualHost *:80>
DocumentRoot "D:\phpStudy\PHPTutorial\WWW\notes\public"
ServerName notes.env
ServerAlias notes.
...
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:\phpStudy\PHPTutorial\WWW\pay_project_dev\public"
ServerName pay.env
ServerAlias pay.
...
</VirtualHost>Nginx 配置
直接做两个代理皆可以
配置一:proxy_local:8007-notes..conf
server {
server_name notes.;
location / {
proxy_pass http://0.0.0.0:8007;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}配置二:proxy_local:8007-pay..conf
server {
server_name pay.;
location / {
proxy_pass http://0.0.0.0:8007;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}Windows 批处理文件 start_service.bat
frpc.exe -c frpc.ini
pause
















