httpslocalhostcaddycaddyfile

Caddy - Setting HTTPS on local domain


I would like to add HTTPS to my local domain, however we can't do this on localhost.

My website goes fine when I run with this Caddyfile

localhost:2020 {
  bind {$ADDRESS}
  proxy / http://192.168.100.82:9000 {
    transparent
  }
}

But I would like to name this website or at least enable HTTPS on it. According to Caddy, you can't do this on localhost, but what if I have a domain name ?

I have tried using my own local address with this Caddyfile

192.168.100.26 {
  bind {$ADDRESS}
  proxy / http://192.168.100.82:9000 {
    transparent
  }
}

All works fine but I still don't have HTTPS...

And when I try to add a random domain name for example

www.mycaddytest.com {
  bind {$ADDRESS}
  proxy / http://192.168.100.82:9000 {
    transparent
  }
}

I got the following error

Activating privacy features...2016/08/18 11:53:26 [www.mycaddytest.com] failed to get certificate: acme: Error 400 - urn:acme:error:connection - DNS problem: NXDOMAIN looking up A for www.mycaddytest.com
Error Detail:
Validation for www.mycaddytest.com:80
Resolved to:

Used: 

I know this error is dues to an unexisting domain name, but is there a way to deal with ?

Just getting HTTPS on localhost or ip address will be enough


Solution

  • Since Caddy 0.9 we can use the tls self_signed attribute.

    Use this Caddyfile

    localhost:2020 {
      bind {$ADDRESS}
      proxy / 192.168.100.82:9000
      tls self_signed
    }
    

    And try https://localhost:2020