feat: support running behind reverse proxy with path based routing #91
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix ##90
Feature
This feature will enable to run MlFlow together with this plugin to run behind a reverse proxy that routes traffic based on the path, e.g.
/models
. This requires some changes in the backend and frontend to use the prefix path. Ideally this prefix path should not be hardcoded or configured.URL generation in the backend
We can use Werkzeugs
ProxyFix
(https://werkzeug.palletsprojects.com/en/stable/middleware/proxy_fix/) to useX-Forwarded-Prefix
from the reverse proxy. This will enableurl_for
to generate the correct URL with the prefixURL generation in the frontend
The UI needs to be configurable to use a base prefix. This could is done via en environment setting which per default is empty.
How to use the feature
The user has to properly configure their reverse proxy as well as override the base prefix in the UI code.
Required changes at Reverse Proxy
In order to work one needs to adjust his reverse proxy to set the needed header. Also at the moment accessing
/models
does not work as the requests for the static mlflow files as well as for the current username (https://github.com/mlflow-oidc/mlflow-oidc-auth/blob/main/mlflow_oidc_auth/hack/menu.html#L42) will ignore the path. I did not want to introduce a new config variable to add the base path here manually so the quick fix is to redirect requests to/models
to/models/
. Then the relative paths will work again.Required changes during build time
As the UI is part of the package, there is no easy way to set the
basePrefix
in the angular configuration without hardcoding it. Therefore, I am overriding it before building the UI. I have not find a way yet to set it dynamically. I tried overriding the compiled javascript in the pip package but was not successful as the production js code gets optimized