How to make nginx to redirect multiple subdomains?

Can I make nginx proxy retry after a short delay if a backend fails to respond?

  • I run mod_wsgi on Apache behind nginx. When I deploy new code I restart the Apache server, which means for about a second any hits to nginx will get an error message. Is it possible to configure nginx to hold the user's connection open for a couple of seconds and then try the backend again, only returning an error if the second attempt fails?

  • Answer:

    upstream myserver { -    server 0.0.0.0:8888; +    server 0.0.0.0:8888 fail_timeout=1s;      server 0.0.0.0:8666 backup;  }

Nathan Schmidt at Quora Visit the source

Was this solution helpful to you?

Other answers

You might want to look into the these two nginx config options * proxy_connect_timeout * proxy_next_upstream If you set your proxy_connect_timeout suitably low (<2s?) and with proxy_next_upstream set to "error" then in theory the next upstream server should be hit after the connect timeout is reached. But as a whole have a look at the nginx proxy module configuration - there might be other goodies: http://wiki.nginx.org/NginxHttpProxyModule

Cody Caughlan

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.