Load Balancing and High Availability

toriacht nginx-forum at nginx.us
Wed Jul 24 22:53:34 UTC 2013


Hi Axel,

Thank you for the reply. I have pasted some of my nginx.conf file below. Can
you conform if i'm setting proxy_next_upstream in correct location please?

Also, is there a way to have fail_timeout increment per fail? i.e if it
failed once try again in 30 secs as it might be minor issue, then if that
fails try a again in 2 mins, then 4 mins etc?


user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request"
'
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #set headers
    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        X-Queue-Start "t=${msec}000";

 # switch to next upstream server in these scenarios
    proxy_next_upstream http_502 http_503 error;

    # load balancer
    # ip_hash provides sticky session
    upstream balancer {
        ip_hash;
        server 127.0.0.1:8180 max_fails=1 fail_timeout=2000s;
        server 127.0.0.1:8280 max_fails=1 fail_timeout=2000s;

    }
    #gzip  on;

    # Load modular configuration files from the /etc/nginx/conf.d
directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        access_log  /var/log/nginx/host.access.log  main;

 location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        }

        #rules for rest
        location /rest/ {
                #proxy_pass http://127.0.0.1:8080/MyApp/rest/;    
                proxy_pass http://balancer/MyApp/rest/;
         }

----
----

Many thanks

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



More information about the nginx mailing list