项目地址: 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:phpStudyPHPTutorialWWWpay_project_devpublic"
3 ServerName pay.env
4 ServerAlias frp.tinywan.top
5 <Directory "D:phpStudyPHPTutorialWWWpay_project_devpublic">
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
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:phpStudyPHPTutorialWWWnotespublic"
3 ServerName notes.env // 本地访问域名
4 ServerAlias frp.tinywan.top // 外网访问域名
5 <Directory "D:phpStudyPHPTutorialWWWnotespublic">
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:phpStudyPHPTutorialWWWnotespublic"
3 ServerName notes.env
4 ServerAlias notes.tinywan.top
5 <Directory "D:phpStudyPHPTutorialWWWnotespublic">
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:phpStudyPHPTutorialWWWpay_project_devpublic"
3 ServerName pay.env
4 ServerAlias pay.tinywan.top
5 <Directory "D:phpStudyPHPTutorialWWWpay_project_devpublic">
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
自定义三级域名
代码语言:javascript复制【1】二级域名:
*.frp.tinywan.top
域名解析A记录到:139.224.239.21
【2】服务端配置:subdomain_host = frp.tinywan.top
【3】客户端配置:
1[notes]
2type = http
3local_ip = 127.0.0.1
4local_port = 80
5use_encryption = false
6use_compression = false
7subdomain = notes
代码语言:javascript复制【4】phpStudy配置
vhosts.conf
:ServerAlias notes.frp.tinywan.top
【5】浏览器访问:http://notes.frp.tinywan.top:8007
即可访问 【6】Nginx做一个反向代理
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
代码语言:javascript复制
vhost.conf
配置
1<VirtualHost *:80>
2 DocumentRoot "D:phpStudyPHPTutorialWWWnotespublic"
3 ServerName notes.env
4 ServerAlias notes.frp.tinywan.top
5 ...
6</VirtualHost>
7
8
9<VirtualHost *:80>
10 DocumentRoot "D:phpStudyPHPTutorialWWWpay_project_devpublic"
11 ServerName pay.env
12 ServerAlias pay.frp.tinywan.top
13 ...
14</VirtualHost>
Nginx 配置
直接做两个代理皆可以
配置一:proxy_local:8007-notes.frp.tinywan.top.conf
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
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
1frpc.exe -c frpc.ini
2pause