'502 Bad Gateway' caused by: EOF

I have an app that is serving API requests. Due to some long processes, the time taken for the application to respond is around 70 secs, but somehow traefik return response of 502 gateway error 10 seconds earlier.

version: '3.7'
services:
  web_server:
    image: traefik:v2.2
    restart: always
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    command: 
      - "--providers.docker=true"
      - "--accesslog=true"
      - "--api.insecure=true"
      - "--log.level=DEBUG"
      - "--api.dashboard=true"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--entrypoints.websecure.transport.respondingtimeouts.writetimeout=240"
      - "--entrypoints.websecure.transport.respondingtimeouts.idletimeout=240"
      - "--entrypoints.websecure.transport.respondingtimeouts.readtimeout=240"
      - "--serverstransport.forwardingtimeouts.responseheadertimeout=240"
      - "--serverstransport.forwardingtimeouts.idleconntimeout=240"
      - "--serverstransport.forwardingtimeouts.dialtimeout=240"
      - "--providers.docker.network=network_default"
      # - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
      - "--certificatesresolvers.cosec.acme.httpchallenge=true"
      - "--certificatesresolvers.cosec.acme.httpchallenge.entrypoint=web"
      - "--certificatesresolvers.cosec.acme.email=xxx@example.com"
      - "--certificatesresolvers.cosec.acme.storage=/data/acme.json"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - traefik_data:/data
      # - /dev/null:/traefik.toml
    stop_grace_period: 120s
    deploy:
      update_config:
        order: start-first
    logging:
      driver: "json-file"
      options:
          max-file: 5
          max-size: 10m
1 Like

To me that sounds like the endpoint is terminating the connection. Maybe turn logging to DEBUG to see if there is more information to be gleaned from Traefik.