Hey all!

I have a bunch of services running on my home server and was looking to expose some of them publicly via Cloudflare tunnel. This is done and working great using the origin server certificate and strict TLS.

Up until now, I’ve been using self-signed certs internally but now I don’t want to deal with the “proceed anyway” crap on browsers. I have Traefik set up to get certs from Cloudflare using DNS challenge and that seems to be working.

So, now my problem is: how do I switch between these certificates for the same URL when I’m internal vs public? I’d rather keep that traffic local if I’m at home, which is also working, I just can’t figure out how to get Traefik to use the appropriate certificate depending on if the request is coming from my LAN or Cloudflare.

Any suggestions? Is there a better way to accomplish what I want to do?

EDIT: Looks like I’m just going full Cloudflare on this one, thanks for your help everyone!

  • ramielrowe@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    ·
    edit-2
    5 months ago

    Just serve the CloudFlare certs. If the URL is the same, it won’t matter. Doesn’t matter if you’re talking to a local private address like 192.166.1.100 or a public IP. If you’re accessing it via a DNS name, that is what is validated, not the underlying IP.

    PS. If you tried this and are having issues. We need more details about how things are set up, and how you are accessing them.

    • shiftymccool@programming.devOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      5 months ago

      If I use the Cloudflare origin server certs, the browser shows insecure and the message is “certificate not trusted” which is the same message as self-signed, if I’m not mistaken. I’m not sure what other details are relevant as I’m still new-ish to the networking portion of this home server thing. I’m happy to answer any questions if you suspect something.

      • IHawkMike@lemmy.world
        link
        fedilink
        English
        arrow-up
        3
        ·
        5 months ago

        You said Traefik is getting certs from Cloudflare, but do you mean it’s getting Let’s Encrypt certs using a CF DNS challenge? And if that is the case, then your browser should trust the Traefik endpoint since LE certs are publicly trusted.

        Are you sure you’re hitting Traefik when you get a cert warning? You need to update your internal DNS if not.

      • ramielrowe@lemmy.world
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        5 months ago

        I somewhat wonder if CloudFlare is issuing two different certs. An “internal” cert your servers use to serve to CloudFlare, which uses a private CA only valid for CloudFlare’s internal services. CloudFlare’s tunnel service validates against that internal CA, and then serves traffic using an actual public CA signed cert to public internet traffic.

        Honestly though, I kinda think you should just go with serving everything entirely externally. Either you trust CloudFlare’s tunnels, or you don’t. If you don’t trust CloudFlare to protect your services, you shouldn’t be using it at all.

        • ramielrowe@lemmy.world
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          5 months ago

          Here’s a drawing of what I think might be happening to your private traffic: traffic diagram

          One major benefit to this approach is CloudFlare does not need to revoke an entire public certificate authority (CA) if a singular private tunnel’s Certificate Authority is compromised.

      • i_am_not_a_robot@discuss.tchncs.de
        link
        fedilink
        English
        arrow-up
        2
        ·
        5 months ago

        That sounds like Cloudflare is giving you certificates intended only to be used for talking to Cloudflare.

        You might be able to do it if Cloudflare sends a different SNI. It’s probably better if you get real certificates from Let’s Encrypt and just use those.