Hi
I'm using Traefik to manage several Laravel/Wordpress/... apps in a docker environment. Traefik is running in it's own docker container and is used to gain access to my various apps via HTTPS. All of which works fine - probably plenty of room for improvement if an expert were to look at it but I'm happy that it works.
Most apps work with only one domain, but one app in fact uses 8 different domains. So basically we have one default domain (let's say foo.local) which I currently have set up and which works, and also a list of "support" domains which are used in certain situations (e.g. bar.local, foo-status.local, bar-status.local,...). The app takes care of how all of these domains are handled, meaning which information is to be shown to the user etc. My problem is: I don't know how to set it up so that Traefik knows that my app can support all of these domains.
Below is my current docker-compose file for the app. When I do it like this, the default domain still works but I get a 404 nginx error page on the new domain. Aside from the file below, I also updated the laravel.conf file mentioned there to include all of the domains. All virtual hosts are identical except for the URL, for obvious reasons. They all point to the same root directory (app/public in my case, because Laravel wants it that way). If you'd like me to include that here, be sure to let me know. I doubt the error is in there though.
version: '3'
services:
nginx:
container_name: foo_nginx
build: docker/nginx
links:
- php
volumes:
- ./:/app:cached
restart: "unless-stopped"
labels:
- "traefik.enable=true"
- "traefik.http.routers.foo-secure.entrypoints=https"
- "traefik.http.routers.foo-secure.rule=Host(`foo.local`)"
- "traefik.http.routers.foo-secure.middlewares=foo-security"
- "traefik.http.routers.foo-secure.tls.certresolver=myhttpchallenge"
- "traefik.http.middlewares.foo-security.headers.browserXSSFilter=true"
- "traefik.http.middlewares.foo-security.headers.customFrameOptionsValue=SAMEORIGIN"
- "traefik.http.middlewares.foo-security.headers.forceSTSHeader=true"
- "traefik.http.middlewares.foo-security.headers.frameDeny=true"
- "traefik.http.middlewares.foo-security.headers.SSLHost=foo.local"
- "traefik.http.middlewares.foo-security.headers.SSLRedirect=true"
- "traefik.http.middlewares.foo-security.headers.STSIncludeSubdomains=true"
- "traefik.http.middlewares.foo-security.headers.STSSeconds=63072000"
- "traefik.http.routers.bar-status-secure.entrypoints=https"
- "traefik.http.routers.bar-status-secure.rule=Host(`aanbieders-status.local`)"
- "traefik.http.routers.bar-status-secure.middlewares=bar-status-security"
- "traefik.http.routers.bar-status-secure.tls.certresolver=myhttpchallenge"
- "traefik.http.middlewares.bar-status-security.headers.browserXSSFilter=true"
- "traefik.http.middlewares.bar-status-security.headers.customFrameOptionsValue=SAMEORIGIN"
- "traefik.http.middlewares.bar-status-security.headers.forceSTSHeader=true"
- "traefik.http.middlewares.bar-status-security.headers.frameDeny=true"
- "traefik.http.middlewares.bar-status-security.headers.SSLHost=bar-status.local"
- "traefik.http.middlewares.bar-status-security.headers.SSLRedirect=true"
- "traefik.http.middlewares.bar-status-security.headers.STSIncludeSubdomains=true"
- "traefik.http.middlewares.bar-status-security.headers.STSSeconds=63072000"
networks:
- web
- foo
php:
container_name: foo_php
build: docker/php
links:
- db
volumes:
- ./:/app:cached
working_dir: /app
restart: "unless-stopped"
networks:
- web
- foo
db:
container_name: foo_db
image: mariadb
command: --max_allowed_packet=67108864
ports:
- "34001:3306"
volumes:
- ./tests/_data/functional-dump.sql:/docker-entrypoint-initdb.d/data.sql:cached
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: foo
MYSQL_USER: foo_user
MYSQL_PASSWORD: foo_pwd
DNSDOCK_ALIAS: mysql.foo.develop
restart: "unless-stopped"
networks:
- web
- foo
testdb:
container_name: foo_test_db
image: mariadb
command: --max_allowed_packet=67108864
ports:
- "34002:3306"
volumes:
- ./tests/_data/functional-dump.sql:/docker-entrypoint-initdb.d/data.sql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: foo
MYSQL_USER: foo_user
MYSQL_PASSWORD: foo_pwd
DNSDOCK_ALIAS: mysql.foo.test
restart: "unless-stopped"
networks:
- web
- foo
node:
container_name: foo_node
build:
context: .
dockerfile: docker/node/Dockerfile
# image: node:13.0-alpine
volumes:
- ./:/app:cached
- ./node_modules:/app/node_modules:cached
- ~/.ssh/id_rsa:/root/.ssh/id_rsa:ro,cached
expose:
- '9500'
tty: true
environment:
NODE_ENV: development
DNSDOCK_ALIAS: node.foo.develop
restart: "unless-stopped"
networks:
- foo
mailhog:
container_name: foo_mailhog
image: yappabe/mailhog
environment:
DNSDOCK_ALIAS: mailhog.foo.develop
restart: "unless-stopped"
networks:
- foo
networks:
web:
external: true
foo:
internal: true
I tried several other approaches obviously but none give me the result that I want.