title: Nginx upstream active passive
body: <p>I have in my nginx configuration an upstream with 3 server.
  I need to set this configuration in order to priority...
  If my server1 is up all connection go to him.
  If my server1 is down all connection go to server 2
  If my server 2 is down all connection go to server 3.</p>
  
  <p>Is possible this?</p>
  
  <p>I have set ip_hash directive and set the directive backup to my server2 and 3 in my upstream.
  But this seem that don't work.
  Have you any suggest?</p>
  
  <p>Is possibile too add a condition that in my server1 is 404 error go to next server in order?
  Thank you</p>
  
  <p>This is my nginx configuration.. but when IP 192.168.10.1 nginx go in round-robin mode to 192.168.10.2 and 192.168.10.3 and this is not good for my mail webserver</p>
  
  <pre><code>upstream mail {
          #ip_hash;
          server 192.168.10.1:80;
          server 192.168.10.2:80 backup;
          server 192.168.10.3:80 backup;
          #health_check;
      }
  
  
  
  
  server {
      listen       443 ssl;
      server_name  mail.test.com;
      location / {
          proxy_set_header X-Real-IP  $remote_addr;
          proxy_set_header X-Forwarded-For $remote_addr;
          proxy_set_header Host $host;
          proxy_set_header        X-Forwarded-Proto $scheme;
          add_header  Front-End-Https   on;
          proxy_pass http://mail;
      }
  }
  </code></pre>