使用cloudflared代理内网

使用cloudflared代理内网

安装

  • curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64 -o cloudflared
  • chmod +x cloudflared
  • mv cloudflared /usr/bin/

登陆

  • cloudflared login

创建通道

  • cloudflared tunnel create mytunnel

增加通道绑定域名

  • cloudflared tunnel route dns mytunnel dy.xiamen.dev

配置通道服务

  • mkdir /etc/cloudflared/
  • vim /etc/cloudflared/config.yml
tunnel: mytunnel
credentials-file: /root/.cloudflared/155ed863-891d-45e3-b436-da57cde7f8f8.json
ingress:
 # 强制 HTTPS
 - hostname: dy.xiamen.dev
 service: http://127.0.0.1:3001
 originRequest:
 noTLSVerify: true
 # 暴露 SSH,通道需要绑定域名
 - hostname: ssh.xiamen.dev
 service: ssh://127.0.0.1:22
 # 默认 fallback
 - service: http_status:404

启用通道服务

  • cloudflared tunnel run mytunnel

后台启用通道服务

  • vim /etc/init.d/cloudflared
#!/bin/sh /etc/rc.common
START=99
STOP=10
start() {
 echo "Starting cloudflared..."
 /usr/bin/cloudflared --config /etc/cloudflared/config.yml tunnel run > /var/log/cloudflared.log 2>&1 &
}
stop() {
 echo "Stopping cloudflared..."
 killall cloudflared
}
  • chmod +x /etc/init.d/cloudflared
  • /etc/init.d/cloudflared enable
  • /etc/init.d/cloudflared start

标签: none

添加新评论