app, built with Flask. I want to have the following routing :
"/" -> my Flask app
"/foo/" -> Reverse proxy toward http://bar/
So far, I don't have any reverse proxy, so my application looks like :
import app
[...]
if __name__ == '__main__':
app.app.secret_key = 'XXX'
app.app.run(debug=True, use_reloader=False)
I would like to have the whole project only in python. I don't want any Apache or nginx stack (the project is not meant to be on public network). I saw that I could use a Python WSGI server, such as "wsgiserver" in cherrypy, so my app would be:
from cherrypy import wsgiserver
import app
d = wsgiserver.WSGIPathInfoDispatcher({
'/': app.app.wsgi_app
})
server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 8080), d)
if __name__ == '__main__':
server.start()
And if I want to add a reverse proxy in "/foo", I guess I'll just need to :
from cherrypy import wsgiserver
import app
d = wsgiserver.WSGIPathInfoDispatcher({
'/': app.app.wsgi_app,
'/foo/': SOME_WSGI_REVERSE_PROXY
})
server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 8080), d)
if __name__ == '__main__':
server.start()
So my questions are :
- Is there any reverse proxy, written in python, that are WSGI compliant ? (I don't know if any
SOME_WSGI_REVERSE_PROXY
exists) - Would it work with this kind of implementation ?