# Bad Gateway error

**URL:** <https://community.traefik.io/t/bad-gateway-error/19481>\
**Category:** Traefik v2\
**Tags:** docker-swarm\
**Created:** [August 10, 2023, 2:54pm UTC](https://community.traefik.io/t/bad-gateway-error/19481 "2023-08-10T14:54:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![thiarerobert](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/thiarerobert/32/7438_2.png) [@thiarerobert](https://community.traefik.io/u/thiarerobert)\
**Post date:** [August 10, 2023, 2:54pm UTC](https://community.traefik.io/t/bad-gateway-error/19481/1 "2023-08-10T14:54:03Z")

</div>

Hello,  
I am configuring traefik to access my api in https. I have the impression that it works since I don't see any errors in the logs and I can access my whoami in https too. But every time I use my front-end url ([https://dspace.localhost](https://dspace.localhost)), I get a Bad Gateway error.  
here are the contents of my traefik.yml file:

```auto
version: "3.9"

services:

  traefik:
    image: "traefik:v2.9.6"
    container_name: "traefik"
    command:
     
      - "--entrypoints.http.address=:80"
      - "--entrypoints.https.address=:443"
  
      - "--entrypoints.postgres.address=:5432"
      - "--api.insecure=true"
      - "--api.dashboard=true"
      
   
      - "--providers.docker=true"
      - "--providers.docker.swarmmode=true"
      - "--providers.docker.network=traefik-net"
      - "--providers.docker.exposedbydefault=false"
      - "--providers.file.filename=/configuration/certificate.yml"
      - "--providers.file.watch=true"
      
    ports:
      - "80:80"
      - "8888:8080"
      - "443:443"
      
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "/C/opt/Savoirs_udes_project/DSpace7/volumes/configuration/:/configuration/"

  whoami:
    image: "traefik/whoami"

    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
        - "traefik.http.routers.whoami.entrypoints=https"
        - "traefik.http.services.whoami.loadbalancer.server.port=80"
        - "traefik.http.routers.whoami.tls=true"

    networks:
      - traefik-net

networks:
  traefik-net:
    driver: overlay
    external: true
  dspace:
    driver: overlay
    external: true

```

* * *

certificate.yml:

```auto
tls:
  certificates:
    certFile = "/C/opt/Savoirs_udes_project/DSpace7/volumes/tls/local-cert.crt"
    keyFile = "/C/opt/Savoirs_udes_project/dSpace7/volumes/tls/local-key.key"

```

* * *

my\_front-end.yml:

```auto
version: '3.9'
networks:
  dspace:
    driver: overlay
    external: true
  traefik-net:
    driver: overlay
    external: true
 
services:
  dspace-angular:
    environment:
      DSPACE_UI_SSL: 'true'
      DSPACE_UI_HOST: dspace.localhost
      DSPACE_UI_PORT: '4000'
      DSPACE_UI_NAMESPACE: /
      DSPACE_REST_SSL: 'true'
      DSPACE_REST_HOST: dspace-api.localhost
      DSPACE_REST_PORT: 443
      DSPACE_REST_NAMESPACE: /server
      NODE_OPTIONS: "--max-old-space-size=5120"

    image: thir2608/savoirs_front:latest
    build:
      context: ..
      dockerfile: Dockerfile
    networks:
      - dspace
      - traefik-net
    deploy:
      labels:
          - "traefik.enable=true"        
          - "traefik.http.routers.dspace-angular.entrypoints=https"      
          - "traefik.http.routers.dspace-angular.rule=Host(`dspace.localhost`)"             
          - "traefik.http.routers.dspace-angular.service=dspace-angular"
          - "traefik.http.services.dspace-angular.loadbalancer.server.port=4000"
          - "traefik.http.routers.dspace-angular.tls=true"

```

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [August 10, 2023, 9:03pm UTC](https://community.traefik.io/t/bad-gateway-error/19481/2 "2023-08-10T21:03:19Z")

</div>

The usual reason for "bad gateway" is the use of multiple networks, but you do define the one to use.

Two things I noticed:

1. This feels strange: `image` and `build` at the same time

> [@thiarerobert](#):
>
> ```auto
> image: thir2608/savoirs_front:latest
> build:
> context: ..
> dockerfile: Dockerfile
> 
> ```

1. This feels strange: `driver` and `overlay` at the same time

> [@thiarerobert](#):
>
> ```auto
> traefik-net:
> driver: overlay
> external: true
> 
> ```

---

<div class="post-metadata">

**Author:** ![thiarerobert](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/thiarerobert/32/7438_2.png) [@thiarerobert](https://community.traefik.io/u/thiarerobert)\
**Post date:** [August 11, 2023, 2:30pm UTC](https://community.traefik.io/t/bad-gateway-error/19481/3 "2023-08-11T14:30:25Z")

</div>

Thank you for your reply.  
You're right about me using image and build in my docker-compose, in fact I was inspired by an existing docker-compose file.  
For the network, I use traefik-net and I removed external:true but the error still persists.  
What's strange is that my front-end and back-end have almost the same tls configuration, yet I can access the api in https.

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [August 11, 2023, 9:02pm UTC](https://community.traefik.io/t/bad-gateway-error/19481/4 "2023-08-11T21:02:17Z")

</div>

You need to use a common Docker network. By itself compose creates an isolated network per file.

So you either need to create one manually in CLI and use `external` in both compose files or you create it in one compose file with `attachable: true` and `name:` and in the other one use `external: true`.

---

<div class="post-metadata">

**Author:** ![thiarerobert](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/thiarerobert/32/7438_2.png) [@thiarerobert](https://community.traefik.io/u/thiarerobert)\
**Post date:** [August 15, 2023, 6:27pm UTC](https://community.traefik.io/t/bad-gateway-error/19481/5 "2023-08-15T18:27:37Z")

</div>

Yes, I saw that my service was connecting to a different network than traefik. So I manually created my network.  
Thanks for your help.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [August 18, 2023, 6:27pm UTC](https://community.traefik.io/t/bad-gateway-error/19481/6 "2023-08-18T18:27:57Z")

</div>

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
