下载
https://github.com/fatedier/frp/releases
包:frp_0.14.1_linux_amd64和frp_0.14.1_windows_amd64
配置服务器端frps.ini,启动nohup ./frps -c ./frps.ini &
# frps.ini [common] bind_port = 7000 vhost_http_port = 8888
配置nginx(先配置二级域名解析),重启nginx -s reload
#test server { listen 80; server_name t.maoriaty.top; expires 300d; gzip on; location / { proxy_pass http://127.0.0.1:8888; proxy_redirect default; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
配置客户端frpc.ini
# frpc.ini [common] server_addr = 47.52.199.163 server_port = 7000 [web] type = http local_port = 80 custom_domains = t.maoriaty.top
新建批处理(代理本地服务器.bat)
cd /d "C:\Program Files\softwore\frp_0.14.1_windows_amd64" start ./frpc -c ./frpc.ini
新建node测试80端口服务器app.js
let express = require('express'); let app = express(); app.get('/',(req,res)=>{ res.send("this is txt ..."); }) app.get('/index',(req,res)=>res.sendFile(__dirname + '/index.html')) let server = app.listen('80',()=>{ console.log('port === %s',server.address().port); })
启动批处理,再启动node app.js,即可再浏览器中输入t.maoriaty.top查看是否代理成功