【保姆级】frp内网穿透

场景:本地调试微信生态的回调时,如果全用线上调试,那就太恶心人了,所以我们今天简单说下frp内网穿透

一、安装和配置

frp下载地址:
https://github.com/fatedier/frp/releases

简单说一下:

服务器用的是frps,客户端用的是frpc,对应的配置就是对应的toml

在这里插入图片描述

客户端配置

# 服务器IP地址
serverAddr = "182.*.*.*"
# 服务器对应绑定端口
serverPort = 15443
auth.token = "C0mAAnJkgrrc56DL"
transport.tcpMax = true

[[proxies]]
name = "web"
type = "http"
# 本地运行项目对应的端口
localPort = 8000
# 映射的域名
customDomains = ["a.test.cn"]

服务端配置

# 服务端绑定的端口
bindPort = 15443
kcpBindPort = 15443
webServer.port = 6001
webServer.user = "bnX1IwgA"
webServer.password = "d8gZciK6KmrFp2rj"
vhostHTTPPort = 18080
vhostHTTPSPort = 18443
auth.token = "C0mAAnJkgrrc56DL"

二、运行

# 先运行服务端,即我们的服务器
./frps -c ./frps.toml
# 后运行客户端,即我们本地电脑
./frpc -c ./frpc.toml

因为服务端我们的80端口一般被nginx占用了,所以我们直接访问 a.test.cn:18080就可以了
在这里插入图片描述

三、骚操作

因为我们的指向的是18080端口,但是一般微信需要我们直接使用80端口,那么我们直接配置nginx的vhost再转一次域名就ok了,这样我们就可以直接使用另一个域名的80端口,访问了

location ^~ / {
  proxy_pass "http://a.test.cn:18080/";
}

在这里插入图片描述

四、systemctl配置服务项

# 在/etc/systemd/system目录添加frp.service文件,为以下内容,更改对应的ExecStart选项
[Unit]
Description=Frp Service
After=network.target

[Service]
ExecStart=/www/wwwroot/frp/frps -c /www/wwwroot/frp/frps.toml
Restart=on-failure
RestartSec=10s
WorkingDirectory=/www/wwwroot/frp
# 重载
sudo systemctl daemon-reload
# 启动
systemctl start frp
# 获取状态
systemctl status frp
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值