title: Traefik won't route past nginx frontend and unable to connect to backend
body: <p>I am a little new to the whole deploy for production world and I am stuck. Essentially, I can't get traefik to route to our backend. It will work if I configure nginx to be our proxy, but I want traefik to do that and have nginx only serving the frontend files. I will do my best to post the code below to give a full picture. Any help is appreciated.</p>
  <p><strong>deployment.yml</strong></p>
  <pre><code>version: '3.7'
  
  services:
    backend:
      build: ../api
      restart: unless-stopped
      depends_on:
        - db
      command: &gt;
          bash -c &quot;python manage.py makemigrations
          &amp;&amp; python manage.py migrate
          &amp;&amp; export DJANGO_SETTINGS_MODULE=api.settings.development
          &amp;&amp; gunicorn api.wsgi --workers=2 --timeout 300 -b 0.0.0.0:8000&quot;
      env_file: .env
      environment:
        - DB_HOST=mongodb
      expose:
        - &quot;8000&quot;
      networks:
        - local
        - web
      labels:
        - &quot;traefik.enable=true&quot;
        - &quot;traefik.docker.network=web&quot;
        - &quot;traefik.http.routers.backend.rule=(Host(`mydomain.com`) &amp;&amp; PathPrefix(`/be`))&quot;
        - &quot;traefik.http.routers.backend.entrypoints=web, websecure&quot;
        - &quot;traefik.http.routers.backend.middlewares=backend-stripprefix&quot;
        - &quot;traefik.http.middlewares.backend-stripprefix.stripprefix.prefixes=/be&quot;
        - &quot;traefik.http.routers.backend.tls=true&quot;
        - &quot;traefik.http.routers.backend.certresolver=letsencrypt&quot;
    frontend:
      build: ../frontend
      restart: unless-stopped
      env_file: .env
      expose:
        - &quot;80&quot;
      networks:
        - web
      labels:
        - &quot;traefik.enable=true&quot;
        - &quot;traefik.http.routers.vue.rule=Host(`mydomain.com`)&quot;
        - &quot;traefik.http.routers.vue.entrypoints=web, websecure&quot;
        - &quot;traefik.http.routers.vue.tls=true&quot;
        - &quot;traefik.http.routers.vue.tls.certresolver=letsencrypt&quot;
        - &quot;traefik.docker.network=web&quot;
    db:
      image: mongo:latest
      environment:
        - MONGO_DATA_DIR=/data/db
      volumes:
        - data:/data/db
      expose:
        - &quot;27017&quot;
      command: mongod --quiet
      networks:
        - local
      restart: always
  
  networks:
    local:
      external: false
    web:
      external: true
  volumes:
    data:
  </code></pre>
  <p><strong>Dockerfile (frontend)</strong></p>
  <pre><code>#build stage
  FROM node:lts-alpine as build-stage
  RUN apk update &amp;&amp; apk upgrade &amp;&amp; apk add --no-cache git
  WORKDIR /frontend
  COPY package*.json ./
  RUN npm install
  COPY . .
  RUN npm run build
  
  # production stage
  FROM nginx:stable-alpine as production-stage
  COPY --from=build-stage /frontend/dist /usr/share/nginx/html
  RUN rm /etc/nginx/conf.d/default.conf
  COPY nginx.conf /etc/nginx/conf.d
  EXPOSE 80
  CMD [&quot;nginx&quot;, &quot;-g&quot;, &quot;daemon off;&quot;]
  </code></pre>
  <p><strong>nginx.conf</strong></p>
  <pre><code>server {
      listen 80;
      server_name _ default_server;
      root /usr/share/nginx/html;
      
      location / {
          try_files $uri $uri/ /index.html;
      }
  }
  </code></pre>
  <p><strong>Dockerfile (backend)</strong></p>
  <pre><code>FROM python:3.8
  ENV PYTHONUNBUFFERED=1
  RUN groupadd -r api-user \
    &amp;&amp; useradd --no-log-init -rmg api-user api-user \
    &amp;&amp; pip install pipenv
  
  ADD . /api
  WORKDIR api
  RUN mkdir /static
  COPY Pipfile Pipfile.lock ./
  RUN pipenv install --system --deploy
  USER api-user
  </code></pre>
  <p><strong>traefik.yml</strong></p>
  <pre><code>version: '3.7'
  
  services:
      reverse-proxy:
        image: traefik:livarot
        restart: unless-stopped
        expose:
          - &quot;8080&quot;
        ports:
          - &quot;80:80&quot;
          - &quot;443:443&quot;
        networks:
            - web
        volumes:
          - &quot;/var/run/docker.sock:/var/run/docker.sock&quot;
          - &quot;./traefik.toml:/traefik.toml&quot;
          - &quot;./traefik_dynamic.toml:/traefik_dynamic.toml&quot;
          - &quot;./acme.json:/acme.json&quot;
        labels:
          - &quot;traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https&quot;
          - &quot;traefik.http.routers.redirs.rule=hostregexp(`{host:.+}`)&quot;
          - &quot;traefik.http.routers.redirs.entrypoints=web&quot;
          - &quot;traefik.http.routers.redirs.middlewares=redirect-to-https&quot;
          - &quot;traefik.http.services.traefik.loadbalancer.server.port=8080&quot;
          - &quot;traefik.http.routers.traefik.tls=true&quot;
          - &quot;traefik.http.routers.traefik.tls.certresolver=letsencrypt&quot;
          - &quot;traefik.http.middlewares.securityHeaders.headers.stsSeconds=63072000&quot;
          - &quot;traefik.http.middlewares.securityHeaders.headers.frameDeny=true&quot;
          - &quot;traefik.http.middlewares.securityHeaders.headers.browserXssFilter=true&quot;
          - &quot;traefik.http.middlewares.securityHeaders.headers.contentTypeNosniff=true&quot;
  
  networks:
    web:
      external: true
  </code></pre>
  <p><strong>traefik.toml</strong></p>
  <pre><code>[entryPoints]
    [entryPoints.web]
      address = &quot;:80&quot;
  
    [entryPoints.websecure]
      address = &quot;:443&quot;
  
  [log]
    level = &quot;DEBUG&quot;
    format = &quot;common&quot;
  
  [api]
    dashboard = true
  
  [providers.docker]
    endpoint = &quot;unix:///var/run/docker.sock&quot;
    watch = true
    exposedByDefault = false
  
  [certificatesResolvers.letsencrypt.acme]
    email = &quot;myemail&quot;
    storage = &quot;acme.json&quot;
    [certificatesResolvers.letsencrypt.acme.httpChallenge]
      entryPoint = &quot;web&quot;
  </code></pre>