Skip to content

Repository for YouTube tutorial on how to use a single "Traefik" Docker container to host as many projects as you want in a single server.

License

Notifications You must be signed in to change notification settings

sesto-dev/one-traefik-multiple-projects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Screenshot (11)

one-traefik-multiple-projects

This repo demonstrates how to use a single Traefik Docker container as a reverse proxy for multiple projects, each with different domains. Instead of manually installing and configuring a reverse proxy for a server, you can deploy this pre-configured Traefik container and easily add as many projects with as many domains as you need.

root/
├── traefik/
│ ├── docker-compose.yml
├── project-1/
│ ├── docker-compose.yml
├── project-2/
│ ├── docker-compose.yml
├── README.md
└── ... (additional projects)

Prerequisites

Before getting started, ensure you have the following installed on your system:

Getting Started

Follow these steps to set up the Traefik reverse proxy and deploy multiple projects.

1. Clone the Repository

git clone https://github.com/sesto-dev/one-traefik-multiple-projects.git

2. Create Docker Network

Traefik and the projects need to communicate over a shared Docker network.

docker network create traefik-public

3. Traefik Docker Container

Set up the necessary environment variables for Traefik and each project.

cd one-traefik-multiple-projects/traefik

Create a .env file inside the traefik directory:

cp .env.example .env
nano .env

Edit the .env file to set your domain and other necessary variables.

USERNAME=your_admin_username
PASSWORD=your_admin_password
DOMAIN=yourdomain.com
ACME_EMAIL=youremail@domain.com

Note: To generate and set the hashed password in one command for Traefik's HTTP Basic Auth, you can use the following command:

export HASHED_PASSWORD=$(openssl passwd -apr1 $PASSWORD)

Then spin up your Traefik container:

docker compose up -d

4. Project Docker Containers

For each project, create a .env file based on the provided examples and enter the DOMAIN for that project.

cd ../project-1
cp .env.example .env
nano .env`
DOMAIN=project1.yourdomain.com

Then spin up the project container:

docker compose up -d

Repeat for project-2.

5. Verify the Setup

Open your browser and navigate to the domains you've configured. You should see the projects running correctly. You can also visit Traefik's dashboard at https://traefik.yourdomain.com.

About

Repository for YouTube tutorial on how to use a single "Traefik" Docker container to host as many projects as you want in a single server.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published