# Webmail 50-50% load balance not working

**URL:** <https://www.ruby-forum.com/t/webmail-50-50-load-balance-not-working/209255>\
**Category:** NGINX\
**Created:** [July 9, 2011, 12:34pm UTC](https://www.ruby-forum.com/t/webmail-50-50-load-balance-not-working/209255 "2011-07-09T12:34:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [July 9, 2011, 12:34pm UTC](https://www.ruby-forum.com/t/webmail-50-50-load-balance-not-working/209255/1 "2011-07-09T12:34:03Z")

</div>

Hi All ,

I have mail server with SquirrelMail as webmail with busy traffic with  
login / logout . My aim is to do the load balancing of 50-50% and  
reduce the load. For this I have created the following test setup in  
LAN.

The nginx-0.8.33.tar.gz is compiled as ./configure  
–with-http\_ssl\_module

Webmail Interface :-- 192.168.30.200  
back end webmail :-- 192.168.30.221 ( apache )  
back end webmail :-- 192.168.30.222 ( apache )  
mail server IP :-- 192.168.1.223  
webmail URL :-- [http://webmail.exampledomain.com](http://webmail.exampledomain.com) &  
[https://webmail.exampledomain.com](https://webmail.exampledomain.com)

## My problem :–

1. When “ip\_hash” is not mention in below config then the request of  
[http://webmail.exampledomain.com](http://webmail.exampledomain.com) get divert 50-50% to internal mail  
server. But when I login with email id and password and hit enter then  
I am getting logout immediately. I am able to see successfully login  
request on server.

i.e for webmail login load balance is not working in my case.

1. when “ip\_hash” is mention then [http://webmail.exampledomain.com](http://webmail.exampledomain.com)  
divert to only one server and I am able to login and check my mails.  
When I stop one of the apache then the request get divert to other  
server and I am able to login.

That is here its work properly But I also observed that when “ip\_hash”  
is mention the load balance of 50-50% is not working.

## My query :–

1. How to get 50-50% load balancing with webmail where login and logout  
happen ?
2. Is there any extra option need to add in config ?
3. Is the below config is correct.

## My nginx.conf config part :–

upstream backend {  
ip\_hash;  
server 192.168.30.221:80;  
server 192.168.30.222:80;  
}

upstream secure {  
ip\_hash;  
server 192.168.30.221:443;  
server 192.168.30.222:443;  
}

server {  
listen 80;  
server\_name [webmail.exampledomain.com](http://webmail.exampledomain.com);  
location / {  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header Host $http\_host;  
proxy\_redirect off;  
proxy\_max\_temp\_file\_size 0;  
proxy\_pass [http://backend](http://backend);  
}

}

server {  
listen 443;  
ssl on;  
ssl\_certificate /etc/ssl/ssl.pem/webmail.exampledomain.com.crt;  
ssl\_certificate\_key /etc/ssl/ssl.pem/webmail.exampledomain.com.key;  
server\_name [webmail.exampledomain.com](http://webmail.exampledomain.com)  
ssl\_session\_timeout 90m;  
ssl\_protocols SSLv2 SSLv3 TLSv1;  
ssl\_ciphers  
ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;  
ssl\_prefer\_server\_ciphers on;

location / {  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;  
proxy\_set\_header Host $http\_host;  
proxy\_redirect off;  
proxy\_max\_temp\_file\_size 0;  
proxy\_pass [https://secure](https://secure);

----x----x—x-----x----x----x------

Regards  
Jayesh Shinde

Posted at Nginx Forum:

> **[webmail 50-50% load balance not working.](https://forum.nginx.org/read.php?2,212039,212039#msg-212039)**
>
> Hi All , I have mail server with SquirrelMail as webmail with busy traffic with login / logout . My aim is to do the load balancing of 50-50% and reduce the load. For this I have created the following test setup in LAN. The nginx-0.8.33.tar.gz is...
