question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How reach Swagger docs under Traefik proxy?

See original GitHub issue

Hi! I have docker-compose file with the following services:

services:

  reverse-proxy:
    image: traefik:v2.4
    container_name: reverse-proxy
    command: 
      - "--api.insecure=true"
      - "--providers.docker"
    ports:
      - "80:80"
      - "8080:8080"
    labels:
      - traefik.enable=true
      - traefik.docker.network=pred-network
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - pred-network

  api-service:
    image: x86_64/prediction-service:0.8.1
    container_name: api-service
    environment:
      SERVING_SERVICE: model-service
    expose:
      - 8000
    labels:
      - traefik.enable=true
      - traefik.http.routers.api-service.rule=Host(`api.service.localhost`)
    networks:
      - pred-network

Container api-service has python script with one path for POST requests: http://api.service.localhost/predict/. This path works perfectly for POST requests. It looks like Swagger docs should be under http://api.service.localhost/docs/. But when I go to this page I am getting:

Not Found
HTTP Error 404. The requested resource is not found.

Environment:

python==3.8
uvicorn==0.13.4
fastapi==0.63.0
python-multipart==0.0.5
numpy~=1.19.5
Pillow==7.0.0
min-tfs-client==1.0.2

I would appreciate any ideas!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
al-yakubovichcommented, Jun 3, 2021

Removing the trailing slash does not help 😦

0reactions
al-yakubovichcommented, Jun 9, 2021

@gyKa Thanks. I added app = FastAPI(root_path="/api/v1") to script but I still cannot connect.

Also tried to change docker-compose so webapp could have only two pathes:

http://traefik.service.localhost/ -> Traefik UI
http://api.service.localhost/ -> 'Hello-Word' page from api-service

But it does not work either

Here is my updated docker-compose file:

version: '3.8'

services:
  reverse-proxy:
    image: traefik:v2.4
    container_name: reverse-proxy
    command: 
      - "--api.dashboard"
      - "--providers.docker"
    ports:
      - "80:80"
      - "8080:8080"
    labels:
      - traefik.http.routers.traefik.rule=Host(`traefik.service.localhost`)
      - traefik.http.routers.traefik.service=api@internal
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    networks:
      - pred-network
  api-service:
    image: x86_64/prediction-service:0.8.1
    container_name: api-service
    environment:
      SERVING_SERVICE: model-service
    expose:
      - 80
    labels:
      - traefik.http.routers.service.rule=Host(`api.service.localhost`)
      - traefik.http.services.service.loadbalancer.server.port=80
    networks:
      - pred-network

networks:
  pred-network:
Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger UI adds a :80 to the request url when used with https ...
My app is based on an microservice architecture all are running in docker containers with Traefik as a reverse proxy. when I try...
Read more >
API Portal - Traefik Labs documentation
Traefik Enterprise includes an API Portal which groups all the API specifications from your services into a web UI. Read the docs to...
Read more >
Swagger, Spring Boot 2 With a Reverse-Proxy in Docker
This article demonstrates how you can set up Spring Boot 2 with Swagger behind a reverse-proxy locally using NGINX and Docker.
Read more >
Behind a Proxy - FastAPI
In some situations, you might need to use a proxy server like Traefik or Nginx with a configuration that adds an extra path...
Read more >
Implement Træfik Into API Platform Dockerized
Use this custom API Platform docker-compose.yml file which implements ready-to-use Træfik container configuration. Override ports and add labels to tell Træfik ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found