I have a specific service inside docker-compose.yml called 'fastapi', which is based on the fastAPI python package.
fastapi:
image: fastapi
labels:
- "traefik.frontend.rule=PathPrefixStrip:/fastapi"
- traefik.port=5000
volumes:
- ./fastapi:/app
- ./data:/data
traefik route to the the fastapi through localhost/fastapi .
However: There is an internal call to openapi.json where the server search for in /openapi.json, and get a "404 page not found" error. How can I route static files from localhost/openapi.json to localhost/fastapi/openapi.json .
I tried this rule, but it does not work!
labels:
- "traefik.frontend.rule=PathPrefixStrip:/fastapi,Path:/openapi.json"
好吧,我错过了FastAPI文档中的明显答案: https ://fastapi.tiangolo.com/tutorial/sub-applications-proxy/
FastAPI(openapi_prefix="/subapi")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.