0

I currently have a docker setup in which one nginx container serves static contents for a number of wordpress sites and proxies dynamic requests to the respective php-apache containers. When I deploy a new php-apache container I just drop in a new nginx virtualhost configuration and update the service.

This setup is very simple and easy to maintain, but HTTPS certifcate issueing and renewal is a real PITA as things have to be done manually (I use zerossl/client).

Traefik seems to be a great solution for reverse proxy + HTTPS but since it's not a webserver it needs two backends to replicate the above setup, redirecting traffic to a static (nginx) or dynamic (php-apache) container based on the request Host and/or path.

While I think this solution would work fine, I doubles the number of containers I need.

I could keep using my nginx proxy as a single backend to all Traefik frontends, effectivley using Traefik only as a HTTPS endpoint, but that seems a little bit of an overkill.

I'm wondering if anyone can suggest a better setup.

Thanks

jeremyjr
  • 375
  • 2
  • 7
  • 15

1 Answers1

1

Have a loook on some of my "real world" exmaples: https://github.com/Berndinox/compose-v3-collection

1) docker network create proxy -d overlay

2) Start traefik/proxy.yml - docker stack deploy -c proxy.yml Attention: If launching more then one traefik container AND you'd like to use ACME you have to store the Config inside a Key-Value Store (Consul, ETCD). A mounted volume would not work in a multiinstance env with ACME. Normal Certificates (.crt,.key) would work and can be defined inside traefik.toml.

3) Create you Services and tag them for traefik, eg Wordpress:

  wordpress:
      image: wordpress
      environment:
        - WORDPRESS_DB_USER=wordpress
        - WORDPRESS_DB_PASSWORD=${DBPWD}
        - WORDPRESS_DB_HOST=mariadb
      volumes:
        - html:/var/www/html
      deploy:
        labels:
          - "traefik.port=80"
          - "traefik.docker.network=proxy"
          - "traefik.frontend.rule=Host:${WWWDOMAIN}"
          - "traefik.backend=wordpress"
          - "traefik.frontend.entryPoints=http,https"
        replicas: 1
      networks:
        proxy:
          aliases:
            - wordpress
        default:
      depends_on: 
        - mariadb

Most Containers have there webserver builtin (Wordpress, Nextcloud, minio, ghost ...) that should not be an issue.

You can scale Traefik, you can also scale Wordpress and Traefik is adding the new endpoints automaticly on the fly! Nice, isn't it?

Berndinox
  • 240
  • 1
  • 3
  • 11
  • Hi @Berndinox I finally got a chance to look at your examples. While interesting they don't seem to address my problem: serving static content for my Apache-php containers. – jeremyjr Oct 01 '18 at 06:31