鸣谢
感谢大佬dearjoe写的主题https://bbs.histb.com/d/240-cloudflared-https
以及神雕大佬的教程https://dl.ecoo.top:2096/视频教程/cloudflared内网穿透教程/cf内网穿透教程.mp4
准备工作
1.一个cloudflare的账号,账号内,有至少一个域名.(没有的可以通过别的平台转过来)
2.一个刷好了的盒子
使用脚本
脚本:wget http://8.130.12.3/install-cloudflaretunnel.sh | bash install-cloudflaretunnel.sh
执行了以后首先会下载cloudflared主体文件
root@Hanjinyue:~# wget https://wakuwaku.azurewebsites.net/api/cdn?url=https://github.com/cloudflare/cloudflared/releases/download/2022.5.1/cloudflared-linux-arm -O /usr/bin/cloudflared
--2023-05-24 18:50:59-- https://wakuwaku.azurewebsites.net/api/cdn?url=https://github.com/cloudflare/cloudflared/releases/download/2022.5.1/cloudflared-linux-arm
Resolving wakuwaku.azurewebsites.net (wakuwaku.azurewebsites.net)... 20.43.67.35
Connecting to wakuwaku.azurewebsites.net (wakuwaku.azurewebsites.net)|20.43.67.35|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified
Saving to: ‘/usr/bin/cloudflared’
/usr/bin/cloudflared [ <=> ] 27.90M 13.1MB/s in 2.1s
2023-05-24 18:51:04 (13.1 MB/s) - ‘/usr/bin/cloudflared’ saved [29256770]
然后会出现这个
root@Hanjinyue:~# cloudflared login
A browser window should have opened at the following URL:
https://dash.cloudflare.com/argotunnel?aud=&callback=https%3A%2F%2Flogin.cloudflareaccess.org%2FmwIT6B-qCBjG_uPzKnTFty5yclRj2rrirukta7Bh0jw%3D
If the browser failed to open, please visit the URL above directly in your browser.
打开中间那个链接
在这里点击一下
点了以后会出来一个弹窗,点击授权.
然后会进到这个页面:
ID在最后一行(不出意外的话)
然后按照自己的要求配置
最后会进到另一个vim页面
cloudflared tunnel route dns cloudflare [前缀 上面设置的].>域名.顶域 #这里是config.yml里面配置的网址,一定要修改这里然后退出就会执行.
cloudflared service install
systemctl start cloudflared
如果看到如下内容,则成功映射,可以访问链接查看.
2023-05-24T09:44:49Z INF Added CNAME XXXX.XXXXX.top which will route to this tunnel tunnelID=XXXXX4e-5XXX-XXX6-aXX8-a6XXXXXX631
2023-05-24T09:44:49Z INF Using Systemd
2023-05-24T09:45:03Z INF Linux service for cloudflared installed successfully