Re: Upstream Fallback if Backends can´t be reached

kperas nginx-forum at nginx.us
Fri Dec 16 13:03:41 UTC 2011


here is my current nginx.conf:

##########################################
user  nginx;
worker_processes  1;
error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
  upstream example-online {
       healthcheck_enabled;
       healthcheck_delay 5000;
       healthcheck_timeout 5000;
       healthcheck_failcount 1;
       server 10.194.1.107:8080  max_fails=2  fail_timeout=2s weight=2;
    ## server 10.194.1.108:8080  max_fails=2  fail_timeout=2s weight=2;
       sticky;
       ip_hash;
  }
  upstream example-org {
       healthcheck_enabled;
       healthcheck_delay 5000;
       healthcheck_timeout 5000;
       healthcheck_failcount 1;
       server 10.194.1.107:8090  max_fails=2  fail_timeout=2s weight=2;
    ## server 10.194.1.108:8090  max_fails=2  fail_timeout=2s weight=2;
       sticky;
       ip_hash;
  }
   gzip on;
server {
    listen 10.194.100.50:80;
    server_name example.de www.example.de;
    rewrite ^ http://www.testing.de permanent;
}
server {
    ssl on;
    ssl_prefer_server_ciphers on;
    ssl_protocols  SSLv3 TLSv1;
    ssl_ciphers  HIGH:!SSLv2:!ADH:!aNULL:!eNULL:!NULL;
    listen 10.194.100.50:443 ssl;
    ssl_certificate ssl/nginx-test.crt;
    ssl_certificate_key ssl/nginx-test.key;
    keepalive_timeout 60;
    server_tokens off;
        proxy_intercept_errors on;
if ($request_method !~ ^(GET|HEAD|POST)$ ) {
          return 444;
}
if ($http_user_agent ~* LWP::Simple|BBBike|wget) {
             return 403;
}
if ( $http_referer ~*
(babes|forsale|girl|jewelry|love|nudit|organic|poker|porn|sex|teen) ) {
          return 403;
}
    server_name example-org;
    location /example-org {
      proxy_pass http://example-org;
          error_page 400 401 404 408 502 503 504 /error/error.html;
    }
    server_name example-online;
    location /example-online {
      proxy_pass http://example-online;
          error_page 400 401 404 408 502 503 504 /error/error.html;
    }
        location /error {
        root /var/www;
        }
		location / {
		root /var/www/error;
		index error.html;
		}
  }
}
###########################

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,220113,220162#msg-220162



More information about the nginx mailing list