# HTTPS backend API call on exposed port 8080 just return 404

**URL:** <https://community.traefik.io/t/https-backend-api-call-on-exposed-port-8080-just-return-404/21392>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [February 6, 2024, 3:22pm UTC](https://community.traefik.io/t/https-backend-api-call-on-exposed-port-8080-just-return-404/21392 "2024-02-06T15:22:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgod](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@mgod](https://community.traefik.io/u/mgod)\
**Post date:** [February 6, 2024, 3:22pm UTC](https://community.traefik.io/t/https-backend-api-call-on-exposed-port-8080-just-return-404/21392/1 "2024-02-06T15:22:42Z")

</div>

Hi all, iam very very new to traefik and need some help with my problem:  
I have a Traefik setup with just a frontend (served via https on port 443 -\> works!) and a backend on port 8080. This does not work and i really dont understand why?? There is no issue on the application layer, there has to be a configuration issue on my side regarding traefik ☹ My frontend need to make API calls via https! My code for workink frontend:

```auto
version: '3'
services:
   frontend:
      image: nginx:latest
      volumes:
        - ./dist:/usr/share/nginx/html
        - ./nginx_conf/nginx.conf:/etc/nginx/conf.d/default.conf
      networks:
         - default
         - web
      labels:
         - traefik.enable=true
         - traefik.http.routers.frontend.rule=Host(`my-domain.info`)
         - traefik.http.routers.frontend.tls=true
         - traefik.http.routers.frontend.tls.certresolver=lets-encrypt
         - traefik.http.services.frontend.loadbalancer.server.port=443 # on 443 nginx is listening
networks:
   web:
      external: true

```

So if i call: [https://my-domain.info](https://my-domain.info), the frontend listening on port 443 gets triggered. Perfect!  
My code on not working backend:

```auto
version: '3'
services:
   backend:
      image: node:latest
      volumes:
        - ./dist:/usr/src/app    
      networks:
         - default
         - web
      labels:
         - traefik.enable=true
         - traefik.http.routers.backend.rule=Host(`my-domain.info/backend`)
         - traefik.http.routers.backend.tls=true
         - traefik.http.routers.backend.tls.certresolver=lets-encrypt
         - traefik.http.services.backend.loadbalancer.server.port=8080
      command: node /usr/src/app/index.js
networks:
   web:
      external: true

```

The node server is listening on port 8080, but doest get triggered. I just get an 404 ☹  
I have also tried `my-domain.info:8080` as well as a subdomain. Nothing works.  
Strange because i basically copied the logic from frontend config to backend

So the traefik setup looks like this:

```auto
version: '3'
services:
   traefik:
      restart: unless-stopped
      image: traefik:latest
      networks:
         - web
      ports:
         - "80:80" 
         - "443:443" #frontend
         - "8080:8080"
      volumes:
         - /var/run/docker.sock:/var/run/docker.sock:ro
         - ./acme.json:/acme.json
         - ./traefik.yml:/traefik.yml
         - ./traefik_api.yml:/traefik_api.yml
networks:
   web:
      external: true

```

So the refered traefik.yml looks like this (maybe there is some error?!) Iam no sure if i have to add something to the entryPoint configuration for backend?

```auto
entryPoints:
   web:
      address: ':80'
      http:
         redirections:
            entryPoint:
               to: websecure
               scheme: https
   websecure:
      address: ':443'
   backend:
      address: ':8080'
api:
   dashboard: true
certificatesResolvers:
   lets-encrypt:
      acme:
         email: my-email@gmx.de
         storage: acme.json
         tlsChallenge: {}
providers:
   docker:
      watch: true
      network: web
      exposedByDefault: false
   file:
      filename: traefik_api.yml

```

The remaining traefik\_api.yml is just for the dashboard. This one works fine.

I would appreciate any help very much, because i dont understand, why a [https://my-domain.info/backend](https://my-domain.info/backend) returns a 404. But it is secured, so the TLS stuff seems to be fine. Let me know, if you need any further information.

What i just need at the end is, that my frontend can make [https://my-domain.info/routes](https://my-domain.info/routes) ... and traefik routes these calls to the corresponding backend, which contains these routes.  
Best, Marc

---

<div class="post-metadata">

**Author:** ![youngt2](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/youngt2/32/6055_2.png) [@youngt2](https://community.traefik.io/u/youngt2)\
**Post date:** [February 6, 2024, 4:00pm UTC](https://community.traefik.io/t/https-backend-api-call-on-exposed-port-8080-just-return-404/21392/2 "2024-02-06T16:00:00Z")

</div>

I don't think you can include the path in the Host rule. You should try:

```auto
- traefik.http.routers.backend.rule=Host(`my-domain.info`) && Path(`/backend`)

```

> **[Traefik Routers Documentation - Traefik](https://doc.traefik.io/traefik/routing/routers/#rule)**
>
> In Traefik Proxy, a router is in charge of connecting incoming requests to the Services that can handle them. Read the technical documentation.

You can also adding debug logging to your traefik.yml to look for errors. Actually I think you will see the issue I mentioned in your traefik log without even setting debug - check `docker logs traefik`

```auto
log:
  level: DEBUG

```

> **[Traefik Logs Documentation - Traefik](https://doc.traefik.io/traefik/observability/logs/)**
>
> Logs are a key part of observability in Traefik Proxy. Read the technical documentation to learn their configurations, rotations, and time zones.

---

<div class="post-metadata">

**Author:** ![mgod](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@mgod](https://community.traefik.io/u/mgod)\
**Post date:** [February 6, 2024, 4:49pm UTC](https://community.traefik.io/t/https-backend-api-call-on-exposed-port-8080-just-return-404/21392/3 "2024-02-06T16:49:49Z")

</div>

Hi youngt2,

thank you very much for your replay.

I have tried to add the && Path(`/backend`)  
but it did not solve the issue. Still 404

Regarding the logging i could also not make it work. Where exactly is the place for log keyword?

I have tried this

> **[Enable logging in Traefik](https://jensknipper.de/blog/traefik-logging/)**
>
> In this article I will show you how to activate logging in Traefik. There are two kinds of logs in Traefik, the general log and the access log. We will have a look at both of them and take a deeper look into the possibilities they provide.

set all up like it is describled there...but nothing gets logged. Sorry iam a newbie. But i would appriciate it very much, if you could just give me a hint where do add the log keyword. Could not find it in the official documentation.

---

<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:** [February 6, 2024, 6:15pm UTC](https://community.traefik.io/t/https-backend-api-call-on-exposed-port-8080-just-return-404/21392/4 "2024-02-06T18:15:15Z")

</div>

Does your backend node app respond on path `backend`? Use `PathPrefix()` instead of `Path()`.

---

<div class="post-metadata">

**Author:** ![mgod](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@mgod](https://community.traefik.io/u/mgod)\
**Post date:** [February 6, 2024, 6:47pm UTC](https://community.traefik.io/t/https-backend-api-call-on-exposed-port-8080-just-return-404/21392/6 "2024-02-06T18:47:51Z")

</div>

Hi, i have changed the Path() to PrefixPath(), as you suggested.  
Host(`my-domain`) && PathPrefix(`/backend`)

It returns Cannot GET /backend/, when i try to access this in the browser.

Well, regarding your question. If i expose the backend beside the proxy, i can access it from serverIPv4:8080 and it works fine. But once this is living behind the proxy i cant get it to run ☹ i have really no idea whats wrong

I thought this line is responsible for the response:

- traefik.http.services.backend.loadbalancer.server.port=8080

and the backend is running and listening on port 8080 as well

---

<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:** [February 6, 2024, 7:22pm UTC](https://community.traefik.io/t/https-backend-api-call-on-exposed-port-8080-just-return-404/21392/7 "2024-02-06T19:22:05Z")

</div>

I think `Cannot GET /backend/` is rather telling you that you can not use GET, but should use another method like POST. That is rather an application error, not Traefik.

Enable Traefik access log in JSON format to see which service is throwing the error (Traefik or target app).

`loadbalancer.server.port=8080` tells Traefik to route forwarded requests to this port within the target container.

---

<div class="post-metadata">

**Author:** ![mgod](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@mgod](https://community.traefik.io/u/mgod)\
**Post date:** [February 6, 2024, 7:29pm UTC](https://community.traefik.io/t/https-backend-api-call-on-exposed-port-8080-just-return-404/21392/8 "2024-02-06T19:29:20Z")

</div>

well actually it is working now...i had a testing route i node js which was unfortunately:  
app.get('/', (req, res) =\> {  
res.send('Node js response successfull')  
});

and this was not triggered behind the proxy.

I have changed the route to something else and suddenly node is responsing.

Thank you all for your help guys...jesus this stuff kicks asses
