-
Notifications
You must be signed in to change notification settings - Fork 221
Open
Description
Description:
When running FastAPI behind a proxy (e.g., Nginx) with a path prefix like /inference/newmodel2-23/, we use the root_path parameter and X-Forwarded-Prefix headers. While the internal /docs handler works perfectly, manual implementations using get_swagger_ui_html result in a 404 for the openapi.json file because the proxy prefix is missing from the generated HTML.
Internal FastAPI Context
Looking at the FastAPI source:
Your source code
MLServer/mlserver/rest/endpoints.py
Lines 44 to 47 in a325e52
| async def docs(self) -> HTMLResponse: | |
| openapi_url = "/v2/docs/dataplane.json" | |
| title = "MLServer API Docs" | |
| return get_swagger_ui_html(openapi_url=openapi_url, title=title) |
Expected Behavior
get_swagger_ui_html should ideally have an optional request parameter or a way to automatically detect and prepend the root_path so that documentation ui and routes work when behind a proxy.
Environment (docker containers)
- MLflow image: ghcr.io/mlflow/mlflow:v3.8.1
- Proxy: Nginx
Example Nginx Config
server {
listen 8983;
server_name localhost;
location /inference/newmodel2-23 {
proxy_pass http://fastapi:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Prefix /inference/newmodel2-23;
}
}
Metadata
Metadata
Assignees
Labels
No labels