-
-
Notifications
You must be signed in to change notification settings - Fork 762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mounting flask under subpath through nginx #527
Comments
While not idea, to work around this I did added the base_path to mount the Connexion app under it's final path:
And then modified the nginx.conf to pass the entire path through the proxy by not including a path in the proxy_pass command:
|
I'm currently struggling with the same problem. When using pure flask, it's common to use this ReverseProxied middleware pattern. When using this, the nginx config looks something like this:
When running without a reverse proxy (e.g. with More importantly, flask's connexion's This is problematic, as the entire What is the recommended way of doing this? |
Has anybody found a good solution? |
@ChristianSauer I struggled with this for a while with both connexion and flask-restplus. I have bad news and good news. flask-restplus uses the WSGI https://bitbucket.org/MattF-NSIDC/sscce_flask-rproxy My example goes a little bit further and can run under a proxy container exposed at an arbitrary port. Look at the README for instructions to test for yourself. Looks like flask-restplus is accomplishing this by returning a swagger UI for each request and passing in a URL generated by flask; EDIT: Man, I shouldn't post to github late at night. To correct what I said above about connexion/ More on wsgi variables like |
Hey folks - please have a look at #823 - It aims to solve this problem and includes an example for both flask and aiohttp. I'd love your feedback. Thanks! |
Fixed link: #823 |
Sorry if this is obvious and I just missed how to do it. My flask app is the rest API so http://localhost:5000/swagger.json is correct. However, if I mount it under /api via a proxy_pass in nginx, the swagger ui is still looking for /swagger.json instead of /api/swagger.json
Setting base_path relocates the whole api so I end up with /api/api/my-rest-call once mounted in nginx.
Is there a way to specify the path where the swagger.json file is located? For now I created a rewrite rule on nginx but that is not a long term solution in case multiple Connexion apps are running under the same nginx instance.
The text was updated successfully, but these errors were encountered: