没有公网IP和云主机,如何在公网访问PROXMOX?利用Cloudflared Tunnel来实现!

-
-
2024-01-08

本篇文章主要讲解利用cloudflare tunnel实现proxmox的远程访问。

实现原理如下(图片来源于互联网):

 

 

01 使用cloudflare这里不细讲,上网一搜就有了,主要流程如下:

  • 注册cloudflare账号
  • 将域名托管给cloudflare
  • 创建隧道
  • 实现访问

02 创建隧道
1)在pve物理主机安装cloudflared软件

curl -L --output cloudflared.deb https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb

sudo dpkg -i cloudflared-linux-amd64.deb

2)登录

# 执行以下命令后会弹出一个url,将url复制到浏览器打开并授权即可。
cloudflared tunnel login

3)创建一个隧道,并记录返回的uuid和配置文件路径

cloudflared tunnel create <tunnel-name>

# 返回如下信息
Tunnel credentials written to /home/pi/.cloudflared/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.json. cloudflared chose this file based on where your origin certificate was found. Keep this file secret. To revoke these credentials, delete the tunnel.

Created tunnel pimytunnel with id XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

4)创建配置文件

mkdir /etc/cloudflared
cd /etc/cloudflared
# 创建配置文件
nano config.yaml
# 输入以下内容
tunnel: <tunnel-id>
credentials-file: 配置文件路径
protocol: http2

ingress:
  - hostname: pveweb.xxx.com
    service: https://localhost:8006
    originRequest:
      disableChunkedEncoding: true
      noTLSVerify: true
  - service: http_status:404

5)将隧道解析到域名上

cloudflared tunnel --config config.yaml route dns <tunnel-name> pveweb.xxx.com

6)注册成系统服务

cloudflared service install

7)在/etc/systemd/system下创建cloudflared.service文件

[Unit]
Description=Cloudflare Tunnel
After=network.target

[Service]
ExecStart=cloudflared tunnel --config /etc/cloudflared/config.yaml run <tunnel-name>
Restart=always
RestartSec=5
StartLimitInterval=0

[Install]
WantedBy=multi-user.target

8)启动服务

systemctl daemon-reload
systemctl start cloudflared

9)查看隧道信息

cloudflared tunnel list
# CONNECTIONS 字段有值,说明正常

也可通过web查看隧道状态:

 

 

10)最后就可以访问啦!

 

 

 

-- 完


社长
结果很重要,但更在于过程!
公告

最新评论

加载中...