I have a Django application that is used for time tracking at my institution. It's running as a Docker container, with an Apache web server in front of it (it does HTTP basic auth using LDAP and then redirects to http://django:80/). I now need Traefik to be in front of everything, because I need to integrate Authelia instead of HTTP basic auth. I want to test everything locally first, that's why this is localhost.
This is my docker-compose.yml:
version: '3'
services:
web:
depends_on:
- django
- traefik
expose:
- "${VIRTUAL_PORT}"
networks:
- default
- proxy
labels:
- "traefik.enable=true"
- "traefik.http.routers.chronocommand.rule=Host(`localhost`)"
- "traefik.docker.network=proxy"
- "traefik.http.routers.chronocommand.entrypoints=web,websecure"
django:
expose:
- "80"
ports:
- "8080:80"
- "8000:8000"
- "3000:3000"
volumes:
- ./Services/Chronocommand:/src
traefik:
image: "traefik:v3.0"
ports:
- "80:80"
- "443:443"
- "8888:8080" # Traefik dashboard
networks:
- proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./Services/DevTraefik/:/etc/traefik
networks:
proxy:
external: true
this is my traefik config:
api:
dashboard: true
insecure: true
global:
checkNewVersion: true
sendAnonymousUsage: false
entryPoints:
web:
address: :80
websecure:
address: :443
http:
tls: true
providers:
docker:
exposedByDefault: false
file:
directory: /etc/traefik
watch: true
When I try to access https://localhost i expect to see the django webapp, which works if I access it via http://localhost:8080. Instead I get a "too many redirects" error in my browser and I can see in the apache log that it tries to access the server multiple times. What did I do wrong?
I'm guessing a lot of the details of your project. But suppose that it looks something like this:
The contents of the Django application will differ, but I simply created a Django starter project.
docker-compose.yml(I'm configuring Traefik directly here rather than using a separate configuration file.)apache.confYou can test the following: