Is it possible to configure Nginx to proxy to a uwsgi server (uwsgi_pass
), falling back to a standard http proxy (proxy_pass
) if the uwsgi server is not available?
My development environment runs as a standard HTTP server on a given port, but in production it will be running under a uWSGI socket. I would like to be able to develop my app, then (still on my development machine) launch the the app under a uwsgi server for testing without having to switch my nginx config as well each time. If nginx could be configured to try with the uwsgi_pass, but if it got an error (because the uwsgi server is not running) fall back to the proxy_pass, that would be ideal.
I could also see this being handy in a production environment: normally, just proxy to the local uwsgi socket, but if for some reason that's not working (for some arbitrary definition of not working), proxy to some secondary http server somewhere else. However, for me for now it's just to make development more convenient.