Virtual hosts outside https:// catch all

1. Caddy version 2.0.0:

2. How I run Caddy:

Caddy is running as a systemd service.

a. System environment:

Ubuntu 18.04,caddy installed from apt and running as a service

d. My complete Caddyfile or JSON config:

http:// {
 redir https://{host}{uri}
}
https:// {
 tls {
  on_demand
 }
 reverse_proxy 127.0.0.1:8084
}
example.com {
 reverse_proxy 127.0.0.1:8080
}
www.example.com {
 reverse_proxy 127.0.0.1:8080
}

3. The problem I’m having:

example.com or www.example go to 127.0.0.1:8084 not 127.0.0.1:8080.EDIT:Alright, while writing this post i found that it worked when i left an empty space after the domain and before the bracket.Otherwise it would throw me to :8084.Is an empty space required or is this unexpected behaviour?
Using
www.example.com , example.com {
reverse_proxy 127.0.0.1:8080
}
The sites example.com work but all other domains point to :8080.So i have to make a seperate for www and non-www.Is this intended behaviour?
Thanks!

Does this work?

http:// {
    redir https://{host}{uri}
}

https:// {
    tls {
        on_demand
    }
    reverse_proxy 127.0.0.1:8084
}

example.com, www.example.com {
    reverse_proxy 127.0.0.1:8080
}

The adapted JSON looks correct to me. (i.e. the output of caddy adapt)

Yes, the space is necessary because otherwise the { would be parsed as being part of the domain.

It’s invalid to have a space before the comma.

Hi Francis,

It’s invalid to have a space before the comma.

that seems to have been the problem.Silly me!
Thanks!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.