Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

627
Views
How to serve static files using Traefik and Nginx in docker-compose

I am trying to serve static files using Traefik and Nginx, also docker. My Django application works well, I can access all pages, but can't setup static files serving. When I open site.url/staic/ It redirects me to the 404 page. For the code skeleton, I am using cookiecutter-django.

Here is my docker configuration:

  django:
    build:
      context: .
      dockerfile: ./compose/production/django/Dockerfile
    image: dreamway_team_production_django
    depends_on:
      - postgres
      - redis
    env_file:
      - ./.envs/.production/.django
      - ./.envs/.production/.postgres
    command: /start

  postgres:
    **

  traefik:
    build:
      context: .
      dockerfile: ./compose/production/traefik/Dockerfile
    image: dreamway_team_production_traefik
    depends_on:
      - django
      - nginx
    volumes:
      - production_traefik:/etc/traefik/acme
    ports:
      - "0.0.0.0:80:80"
      - "0.0.0.0:443:443"

  redis:
    **

  nginx:
    image: nginx:1.17.4
    depends_on:
      - django
    volumes:
      - ./config/nginx.conf:/etc/nginx/conf.d/default.conf
      - ./dreamway_team/static:/static

and my config for traefik:

log:
  level: INFO

entryPoints:
  web:
    address: ":80"

  web-secure:
    address: ":443"

certificatesResolvers:
  letsencrypt:
    acme:
      email: "mail"
      storage: /etc/traefik/acme/acme.json
      httpChallenge:
        entryPoint: web

http:
  routers:
    web-router:
      rule: "Host(`[DOMAIN_NAME]`)"
      entryPoints:
        - web
      middlewares:
        - redirect
        - csrf
      service: django

    web-secure-router:
      rule: "Host(`[DOMAIN_NAME]`)"
      entryPoints:
        - web-secure
      middlewares:
        - csrf
      service: django
      tls:
        certResolver: letsencrypt

  middlewares:
    redirect:
      redirectScheme:
        scheme: https
        permanent: true
    csrf:
      headers:
        hostsProxyHeaders: ["X-CSRFToken"]

  services:
    django:
      loadBalancer:
        servers:
          - url: http://django:5000

providers:
  file:
    filename: /etc/traefik/traefik.yml
    watch: true

Any help would be appreciated! Thanks!

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!