【问题标题】:How to reconnect cloudflare tunnel after ip changeip更改后如何重新连接cloudflare隧道
【发布时间】:2021-12-29 13:04:04
【问题描述】:

我在 Docker 映像中使用 cloudflare 隧道。 docker compose 配置

tunnel:
    image: cloudflare/cloudflared:2021.11.0
    command: tunnel --config /etc/cloudflared/config.yml --no-autoupdate run

和 cloudflared 配置

url: http://host.docker.internal:8000
tunnel: ***
credentials-file: /etc/cloudflared/***.json

当我切换主机wifi网络时,主机ip发生变化,隧道断开。

cloudflared tunnel info <NAME>
...
This tunnel has no active connectors.

是否有参数可以周期性地重新连接cloudflared客户端?

【问题讨论】:

    标签: docker cloudflare tunnel reconnect


    【解决方案1】:

    似乎您的 docker 容器无法识别任何更新或 ip4 更改,因为您在虚拟 docker 交换机上运行它。

    如果您使用这些设置在您的机器上尝试 nativ,这应该可以工作:

    # run command
    $ cloudflared tunnel --no-chunked-encoding run <<your_tunnel_name>>
    
    # config.yml in your default cloudflared folder (~/.cloudflared/):
    
    tunnel: 0000001
    credentials-file: .cloudflared/0000001.json
    originRequest: # Root-level configuration
      connectTimeout: 10s
    loglevel: debug
    transport-loglevel: debug
    
    ingress:
      - hostname: example.com
        service: http://localhost:4300
        originRequest:
          connectTimeout: 10s
          tcpKeepAlive: 12s
      - service: http_status:404
    

    这里是重新创建新连接后日志的 sn-p:

    2021-11-18T16:39:27Z DBG rpcconnect: tx (abort = (reason = "rpc: shutdown", type = failed, obsoleteIsCallersFault = false, obsoleteDurability = 0))
    2021-11-18T16:39:27Z ERR Unable to establish connection. error="already connected to this server, trying another address" connIndex=2
    2021-11-18T16:39:27Z ERR Connection terminated error="already connected to this server, trying another address" connIndex=2
    2021-11-18T16:39:27Z DBG rpcconnect: rx (return = (answerId = 1, releaseParamCaps = false, results = (content = <opaque pointer>, capTable = [])))
    2021-11-18T16:39:27Z INF Connection 90277bf3-1708-490b-803e-fbdabbbb1f75 registered connIndex=3 location=FRA
    2021-11-18T16:39:27Z DBG rpcconnect: tx (finish = (questionId = 1, releaseResultCaps = false))
    

    【讨论】:

    • 似乎 docker 容器中的重新连接过程需要很长时间(最多 30 分钟),但它可以工作
    猜你喜欢
    • 1970-01-01
    • 2015-05-18
    • 2023-01-20
    • 2018-05-11
    • 2017-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-10
    相关资源
    最近更新 更多