You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use flask and flask-restx to create multiple rest apis using nginx
In order to support multiple rest services I add locations to the nginx config
I am developing on a remote server, which is also my deployment server (one server for all rest apis)
Each rest api should have its own swagger doc
I am using a blueprint to alter the api.doc as shown in the restx documentation
I have started with just one simple rest api
I find that when serving with flask and gunicorn it works as expected, both the rest endpoint and the swagger doc work
But when I use nginx the endpoint works but the swagger doc is getting "the page you are looking for is not found"
I have been trying to resolve this over the last few days and have found many discussions on this issue dating back many years
All the way back to before flask-restful forked to flask-restx
I see many posted solutions, most involve using some combination of:
defining a custom_ui
changing the nginx location configuration for the reverse-proxy
adding additional nginx locations for swagger.json and swaggerui
I have tried many of these with no success
I see the github appears to have been updated with changes based on this issue.
I searched the restx documentation and could not find an example for my case.
Could someone either reply with the recommended solution or point me to an example for this case.
I have attached my simple restapi file as a text file restapi.txt
I made some progress.
I had to change some things I didn't want to touch like the root location in the nginx.conf
The issue is the path it uses to look for the swaggerui info
These are the js css and swagger.json files
I got the ui to populate but the "try it out" doesn't work
The solution I am trying will not work for multiple rest apis on the same server.
Do you know of any way to control where it looks for the swaggerui files
I am trying to use flask and flask-restx to create multiple rest apis using nginx
In order to support multiple rest services I add locations to the nginx config
I am developing on a remote server, which is also my deployment server (one server for all rest apis)
Each rest api should have its own swagger doc
I am using a blueprint to alter the api.doc as shown in the restx documentation
I have started with just one simple rest api
I find that when serving with flask and gunicorn it works as expected, both the rest endpoint and the swagger doc work
But when I use nginx the endpoint works but the swagger doc is getting "the page you are looking for is not found"
I have been trying to resolve this over the last few days and have found many discussions on this issue dating back many years
All the way back to before flask-restful forked to flask-restx
I see many posted solutions, most involve using some combination of:
defining a custom_ui
changing the nginx location configuration for the reverse-proxy
adding additional nginx locations for swagger.json and swaggerui
I have tried many of these with no success
I see the github appears to have been updated with changes based on this issue.
I searched the restx documentation and could not find an example for my case.
Could someone either reply with the recommended solution or point me to an example for this case.
I have attached my simple restapi file as a text file
restapi.txt
key component versions
Flask==3.0.3
flask-restx==1.3.0
gunicorn==22.0.0
nginx version: nginx/1.14.1
nginx conf
location /restapi {
proxy_pass http://restapi/;
}
upstream restapi {
server unix:/run/gunicorn/restapi.sock;
}
The text was updated successfully, but these errors were encountered: