Home > database >  Traefik and Apache vhosts
Traefik and Apache vhosts

Time:08-11

I'm pretty new to docker world and more to Traefik, so maybe I'm asking silly questions.

We have a docker-compose file with a lamp stack and many vhost to route them.

Yesterday I found traefik, and looks good!, but I have so many questions. First is my docker machine has to have more containers than my own pages (for example a thumbor instance), that why I look into traekif, but also I want to have my page1.mydomain.es and page2.mydomain.es and so on.

I can configure Traefik to route to my thumbor container, but the problem is with my Apache sites. How can I route so many domains to the Apache container, and that my Apache understand and give me the right site?

I know that if I make every site a container, I have fixed that, but I don't like. Just think about having 15 sites and every one of them is an Apache container instance drives me nuts.

CodePudding user response:

i answer my self:

labels:
            traefik.http.routers.apache.rule: Host(`vhost1.local`,`vhost2.local`)

This makes 2 routes to the same service, traefik send the right header and Apache vhost returns the right site.

But this has some problems for me. With that approach, you can generate some Lets Encrypt certs, but it will give ONE cert with vhost1.local as the main SNI and the rest as a secondary.

To fix that, you need to add as many routes as you want, like this:

labels:
            traefik.http.routers.apache1.rule: Host(`vhost1.local`)
            traefik.http.routers.apache2.rule: Host(`vhost2.local`)

This will give 2 certs, each with the host as main SNI

  • Related