上期链接
https://blog.chengbuwan.ink/archives/cloudflaresai-bo-da-shan-ren-mian-fei-nei-wang-chuan-tou本期带来Windows教程,Windows相对比Linux简单,同样的,临时域名看结尾,所有命令都要用管理员权限运行
1.下载与安装
先下载安装包:https://github.com/cloudflare/cloudflared/releases/latest
下载 cloudflared-windows-amd64.exe(64位系统)或 cloudflared-windows-386.exe(32位)
在C盘新建一个文件夹,叫 cloudflared(路径:C:\cloudflared)
把下载的exe文件放进去,重命名为 cloudflared.exe
设置环境变量(重要):
· 按 Win + X → 系统 → 高级系统设置 → 环境变量
· 在“系统变量”里找到 Path → 编辑 → 新建 → 填入 C:\cloudflared
· 一路点确定保存
重新打开PowerShell,输入 cloudflared --version,看到版本号就说明成功了
2.登录cloudflare账号
在PowerShell输入
cloudflared tunnel login会给你链接,你去打开登录授权你想要的域名,授权后会下载一个 cert.pem 文件,把它复制到 C:\Users\你的用户名\.cloudflared\ 文件夹里(没有就手动新建)
3.创建隧道
依旧某神秘PowerShell
在PowerShell执行
cloudflared tunnel create 隧道名字然后回车,执行完会在.cloudflared 文件夹里生成一个 xxx.json 文件(UUID)
4.绑定域名
cloudflared tunnel route dns 隧道名字 你的域名执行这个命令
5.获取隧道UUID
执行
cloudflared tunnel list复制UUID,很重要
6.编写配置文件
在 C:\Users\你的用户名\.cloudflared\ 文件夹里,新建一个文件叫 config.yml,用记事本打开,粘贴下面内容:
tunnel: 你的隧道名字
credentials-file: C:\Users\你的用户名\.cloudflared\你的隧道UUID.json
ingress:
- hostname: 你的域名
service: http://localhost:你要穿透的端口
- service: http_status:404把里面的隧道名字、UUID、域名、端口都替换成你自己的。
注意:hostname后面那一行,service的端口写你要穿透的服务端口,比如 http://localhost:8080
7.后台运行
分别执行
cloudflared service installStart-Service Cloudflared8.临时域名教程
执行
cloudflared tunnel --url http://localhost:端口号他会给你一个临时域名
9.总结
还是一样的,晚高峰(傍晚)延迟大,没有大陆优化
临时域名不推荐长期使用,购买域名看上期结尾
https://blog.chengbuwan.ink/archives/cloudflaresai-bo-da-shan-ren-mian-fei-nei-wang-chuan-tou
评论