Docker: Traefik base configuration

This documentation is part of the HTTPS routing guide. View the full guide here: How to manage HTTP routing and TLS encryption (HTTPS) in your Docker containers.

👋 Welcome to the Stackhero documentation!

Stackhero offers a ready-to-use Docker cloud CaaS (Containers as a Service) solution that provides a host of benefits, including:

  • Easily deploy your containers to production with just a docker-compose up.
  • Customizable domain name secured with HTTPS (for example, https://api.your-company.com, https://www.your-company.com, https://backoffice.your-company.com).
  • Optimal performance and robust security powered by a private and dedicated VM.
  • Effortless updates with just a click.

Save time and simplify your life: it only takes 5 minutes to try Stackhero's Docker CaaS cloud hosting solution and deploy your containers to production!

In all the following configuration examples, you will have to replace <XXXXXX>.stackhero-network.com with your Stackhero for Docker instance domain name.

Below is a basic example of a docker-compose.yml file:

services:
  test:
    image: nginx
    labels:
      - "traefik.enable=true" # Enable Traefik to route traffic to this container
      - "traefik.http.routers.test.rule=Host(`<XXXXXX>.stackhero-network.com`)" # Define the host
      - "traefik.http.routers.test.tls.certresolver=letsencrypt" # Use 'letsencrypt' as the TLS certificate resolver

In this example, a container named test runs using the Nginx image. The key configuration is provided in the labels section. You simply need to copy these lines into your docker-compose.yml file and replace <XXXXXX>.stackhero-network.com with your service domain.

You can deploy the container using:

docker context use <XXXXXX>.stackhero-network.com
docker-compose up

After the container starts, visit https://<XXXXXX>.stackhero-network.com/ to see the "Welcome to nginx!" page.

Nginx welcome pageNginx welcome page

If you do not see the Nginx welcome page, check the Traefik dashboard for possible errors!

With this configuration, HTTP requests sent to <XXXXXX>.stackhero-network.com are routed to your test container and Traefik automatically creates and manages TLS certificates for HTTPS.