Title: Docker Compose: Deploying Multiple Apps with Traefik for SSL/TLS Certificate Routing and Google Cloud DNS Migration to OVH
Introduction
In this article, we will guide you through the process of deploying multiple applications using Docker Compose and Traefik for SSL/TLS certificate routing. We will also discuss the migration of DNS services from Google Cloud DNS to OVH.
Prerequisites
- Docker installed and running
- Docker Compose installed and running
- Access to the applications you want to deploy
- SSL/TLS certificates for your applications
- A domain name registered with OVH
Setting Up the Environment
- Create a
docker-compose.ymlfile with the configuration for your applications and Traefik.
version: '3'
services:
app1:
image: your_app1_image
ports:
- '80:80'
labels:
- "traefik.frontend.rule=Host:app1.example.com"
- "traefik.frontend.headers.SSLRedirect=true"
- "traefik.frontend.headers.FrameDeny=true"
- "traefik.frontend.headers.ContentTypeOptions=true"
- "traefik.frontend.headers.XContentTypeOptions=nosniff"
- "traefik.frontend.headers.XFrameOptions=DENY"
- "traefik.frontend.headers.XXSSProtection=1; mode=block"
- "traefik.port=80"
- "traefik.enable=true"
app2:
image: your_app2_image
ports:
- '80:80'
labels:
- "traefik.frontend.rule=Host:app2.example.com"
- "traefik.frontend.headers.SSLRedirect=true"
- "traefik.frontend.headers.FrameDeny=true"
- "traefik.frontend.headers.ContentTypeOptions=true"
- "traefik.frontend.headers.XContentTypeOptions=nosniff"
- "traefik.frontend.headers.XFrameOptions=DENY"
- "traefik.frontend.headers.XXSSProtection=1; mode=block"
- "traefik.port=80"
- "traefik.enable=true"
traefik:
image: traefik:v2.9
ports:
- '80:80'
- '8080:8080'
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
command: --api --docker --web --logLevel=DEBUG
SSL/TLS Certificate Routing with Traefik
Traefik automatically detects services with the traefik.enable label and configures them based on the traefik.frontend.rule label. In our example, we have set the Host value to the domain name of each application.
Migrating DNS Services from Google Cloud DNS to OVH
- Log in to your OVH Manager: https://www.ovh.com/manager/web/
- Go to the DNS zone management section for your domain.
- Create new DNS records with the appropriate
AorCNAMErecords pointing to the IP addresses of your applications.
Conclusion
With this setup, your applications will be accessible via SSL/TLS, and your DNS services will be managed by OVH. If you encounter any issues during the migration, ensure that your SSL/TLS certificates are correctly configured and that your domain name is properly set up with OVH.