Welcome! Log In Create A New Profile

Advanced

Re: Load Balancing and High Availability

July 24, 2013 06:53PM
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
Subject Author Posted

Load Balancing and High Availability

toriacht July 23, 2013 10:59AM

Re: Load Balancing and High Availability

toriacht July 23, 2013 11:06AM

Re: Load Balancing and High Availability

nitesh July 23, 2013 11:16AM

Re: Load Balancing and High Availability

Axel July 23, 2013 06:04PM

Re: Load Balancing and High Availability

toriacht July 24, 2013 06:53PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 108
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready