frp 供內網穿透服務的工具
frp 供內網穿透服務的工具
修改配置檔案:
[common]
server_addr = frp.yo1c.cc
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 success
phpstudy 配置vhost
<VirtualHost *:80>
DocumentRoot "D:\phpStudy\PHPTutorial\WWW\pay_project_dev\public"
ServerName pay.env
ServerAlias frp.tinywan.top
<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://frp.tinywan.top/?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 = 8080
IP:
139.224.239.21
域名frp.tinywan.top
已經被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 = frp.tinywan.top
phpStudy配置 vhosts.conf
<VirtualHost *:80>
DocumentRoot "D:\phpStudy\PHPTutorial\WWW\notes\public"
ServerName notes.env // 本地訪問域名
ServerAlias frp.tinywan.top // 外網訪問域名
<Directory "D:\phpStudy\PHPTutorial\WWW\notes\public">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
瀏覽器位址列:
http://frp.tinywan.top:8080/index/index/last_insert_id
將會通過外網訪問本地Web專案了
自定義二級域名
服務端配置
[common]
bind_port = 7000
vhost_http_port = 8007
subdomain_host = tinywan.top
token = 2W/WktjD1QB9xX/oDZSnH8mv81xzLNU283ern8YiFtY=
服務端IP:
139.224.239.21
阿里雲域名解析:*.tinywan.top
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.tinywan.top
<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.tinywan.top
<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.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】客戶端配置:
[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.frp.tinywan.top
【5】瀏覽器訪問:
http://notes.frp.tinywan.top:8007
即可訪問【6】Nginx做一個反向代理
server {
server_name notes.frp.tinywan.top;
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.frp.tinywan.top
即可訪問
配置多個客戶端
這裡配置多個客戶端,只要開啟本地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.frp.tinywan.top
...
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:\phpStudy\PHPTutorial\WWW\pay_project_dev\public"
ServerName pay.env
ServerAlias pay.frp.tinywan.top
...
</VirtualHost>
Nginx 配置
直接做兩個代理皆可以
配置一:proxy_local:8007-notes.frp.tinywan.top.conf
server {
server_name notes.frp.tinywan.top;
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.frp.tinywan.top.conf
server {
server_name pay.frp.tinywan.top;
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