Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i have a frontends server with nginx, this serve the static content, and forward by proxy_pass the rest.

I have a problem with the backends servers and this return 403 error randomy, this is in another question.

For a immediately solution, i want only pass if apache return 200, i now have:


upstream balanced {

And in the virtuals:

  server {
      access_log  /var/log/nginx/myweb.access.log main buffer=32k;
      error_log   /var/log/nginx/myweb.error.log info;
      #expires     31d;
      #limit_conn  gulag 5;
      listen      80; # rcvbuf=64k backlog=128;

        include /etc/nginx/proxy_params;

      location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
                access_log off;
                expires 30d;
                root    /srv/www/myweb/httpdocs;

      location / {
        proxy_pass  http://balanced;

I need, in case of 403 response from the backs, try the next. as well as if the server does not respond.

Thanks, sorry my English

share|improve this question
up vote 2 down vote accepted

You may want to check on proxy_next_upstream directive...

I don´t know if I can handle 403 requests on 1.0.x version, but seems easy to customize the code as shows this patch for 0.6.32 and 0.8.7 versions...,4830

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.