# Load Balancing https with sticky connection

**URL:** <https://www.ruby-forum.com/t/load-balancing-https-with-sticky-connection/219202>\
**Category:** NGINX\
**Created:** [April 23, 2012, 6:18pm UTC](https://www.ruby-forum.com/t/load-balancing-https-with-sticky-connection/219202 "2012-04-23T18:18:10Z")\
**Posts on this page:** 2\
**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:** [April 23, 2012, 6:18pm UTC](https://www.ruby-forum.com/t/load-balancing-https-with-sticky-connection/219202/1 "2012-04-23T18:18:10Z")

</div>

Hi to everybody,

first of all I’m very sorry for my English…

This is my scenario:

Internet;

Firewall+nginx as load balancer: pfsense\_1(active) + pfsense\_2(passive)  
in CARP;

Poos servers: 3 x nginx(PHP5-FPM HTTP+HTTPS);

Pfsense 1 and 2 CARP configured with virtual IP (pubblic). Nginx pool  
servers’s ips are all private.

I want to load balance inbound HTTP and HTTPS connections between the 3  
nginx web servers. An importat thing is that the HTTPS connections must  
be “sticky connections”: in HTTPS connections, after login by username  
and password, I setup a php session and therefore when a client starts a  
HTTPS connection it will be always redirected to the same nginx server,  
until it disconnects itself, it closes the page/browser or after a  
timeout (30minutes?) without activity.  
I would like to do that without decript ssl traffic in the load  
balancer. Is it possible using the directive ip\_hash?  
The configuration will be something like this:

upstream poolservers\_http { # HTTP (NO sticky connections…  
server [server1.example.com](http://server1.example.com) max\_fails=1 fail\_timeout=10s;  
server [server2.example.com](http://server2.example.com) max\_fails=1 fail\_timeout=10s;  
server [server3.example.com](http://server3.example.com) max\_fails=1 fail\_timeout=10s;  
}

upstream poolservers\_https { # HTTPS  
ip\_hash; # sticky connections  
server [server1.example.com](http://server1.example.com) max\_fails=1 fail\_timeout=10s;  
server [server2.example.com](http://server2.example.com) max\_fails=1 fail\_timeout=10s;  
server [server3.example.com](http://server3.example.com) max\_fails=1 fail\_timeout=10s;  
}

server { # HTTP  
listen public\_ip:80;  
server\_name [expample.com](http://expample.com);  
location / {  
proxy\_pass http://poolservers\_http;  
}  
}

server { # HTTPS  
listen public\_ip:443;  
server\_name [expample.com](http://expample.com);  
location / {  
proxy\_pass https://poolservers\_https;  
}  
}

thank you very much…

Posted at Nginx Forum:

> **[Load Balancing https with sticky connection](https://forum.nginx.org/read.php?2,225682,225682#msg-225682)**
>
> Hi to everybody, first of all I'm very sorry for my English... This is my scenario: Internet; Firewall+nginx as load balancer: pfsense\_1(active) + pfsense\_2(passive) in CARP;

---

<div class="post-metadata">

**Author:** ![zeux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/5daacb/32.png) [@zeux](https://www.ruby-forum.com/u/zeux)\
**Post date:** [April 26, 2012, 3:24pm UTC](https://www.ruby-forum.com/t/load-balancing-https-with-sticky-connection/219202/2 "2012-04-26T15:24:10Z")

</div>

help me…please…

Posted at Nginx Forum:

> **[Re: Load Balancing https with sticky connection](https://forum.nginx.org/read.php?2,225682,225813#msg-225813)**
>
> Hi to everybody, first of all I'm very sorry for my English... This is my scenario: Internet; Firewall+nginx as load balancer: pfsense\_1(active) + pfsense\_2(passive) in CARP;
