Search code examples
apachedockerreverse-proxyproductiontraefik

multiple container with Traefik (reverse-proxy) solution


I want to be able to have access to multiple containers, on the same host, containing web applications. So, my host is reacheable by an ip adress, and I want, from the outside, be able to access to my container with an URL like :

ip_host/container1

To make it works, I found the Traefik solution. First, I followed the traefick quick start.

So here my docker-compose.yml file:

version: "2"
services:
    traefik:
        image: traefik
        command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG
         ports:
         - "80:80"
         - "8080:8080"
         - "443:443"
         volumes:
         - /var/run/docker.sock:/var/run/docker.sock
         - /dev/null:/traefik.toml
     php1:
         image: php:7.0-apache
         labels:
         - "traefik.backend=php1"
         - "traefik.frontend.rule=Host:php1"
         volumes:
         - ./php1:/var/www/html
     php2:
         image: php:7.0-apache
         labels:
         - "traefik.backend=php2"
         - "traefik.frontend.rule=Host:php2"
         volumes:
         - ./php2:/var/www/html

After

docker-compose up -d

I cannot curl/reach any of my containters with the following command :

curl -H Host:php1 http://host01

Did I understood well the use of Traefick? Is it just the way I build it which is not good? Do I have to put some new entries to /etc/hosts?


Solution

  • Please try:

    curl -H Host:php1 http://php1