mkdir Traefik
touch docker-compose.yaml
cd Traefik
mkdir config
cd config
touch traefik.yaml
vim docker-compose.yaml
services:traefik:networks:-traefikcontainer_name:traefikimage:traefik:v3.1.5ports:-"8090:8000"# HTTP traffic-"8443:9000"# HTTPS traffic-"9090:8080"# Dashboardvolumes:-/var/run/docker.sock:/var/run/docker.sock-./config/traefik.yaml:/etc/traefik/traefik.yaml:rorestart:unless-stoppednginx:networks:-traefikcontainer_name:nginx-demo-1image:nginx:latestlabels:-traefik.enable=true# - traefik.http.routers.nginx-http.rule=Path(`/nginx`)-traefik.http.routers.nginx-http.rule=PathPrefix(`/`)# As we have used / means on nginx is lisiting on http://<host-ip>:8090/ . If we want /nginx we have to configure nginx for the same.-traefik.http.routers.nginx-http.entrypoints=webrestart:unless-stoppednetworks:traefik:external:true
vim config/traefik.yamk
global:checkNewVersion:falsesendAnonymousUsage:falselog:level:DEBUGapi:dashboard:trueinsecure:trueentryPoints:web:address::8000# Internal Traefik port for HTTP trafficwebsecure:address::9000# Internal Traefik port for HTTPS trafficproviders:docker:endpoint:"unix:///var/run/docker.sock"exposedByDefault:false
docker compose up -d
docker logs traefik
docker logs nginx
Testing
Access http://<host-ip>:8090/ in your browser.
If everything is configured correctly, you should see the default NGINX page.