Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to load balance 2 apache/php servers with haproxy Googling around I saw that since version 1.5 dev12, haproxy supports SSL offloading, which as I understand means that there is no need for any extra components in front of haproxy to handle the SSL.

Basically, I followed this article http://blog.exceliance.fr/2012/09/10/how-to-get-ssl-with-haproxy-getting-rid-of-stunnel-stud-nginx-or-pound/ to setup haproxy

Below my config

global
        log 127.0.0.1   local0
        log 127.0.0.1   local1 notice
        #log loghost    local0 info
        maxconn 4096
        chroot /usr/share/haproxy
        uid 99
        gid 99
        daemon
        #debug
        #quiet

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option  redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000

frontend ft_test
  mode http
  bind 0.0.0.0:443 ssl crt /home/prx/haproxy_ssl/haproxy.ssl prefer-server-ciphers
  # other (self described) options are: [ciphers <suite>] [nosslv3] [notlsv1]
  default_backend bk_test


backend bk_test
  mode http
  balance roundrobin
  server  inst1 10.1.2.43:80 check inter 2000 fall 3
  server  inst2 10.1.2.142:80 check inter 2000 fall 3

The problem is that the backend servers both receive requests at the same time I mean, I refresh the page once and every time 3 requests appear on the web server's log A sample of the logs

10.1.2.138 - - [24/Jan/2013:12:16:09 -0500] "GET /index.php HTTP/1.1" 200 67170
10.1.2.138 - - [24/Jan/2013:12:16:09 -0500] "GET /index.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42 HTTP/1.1" 200 2524
10.1.2.138 - - [24/Jan/2013:12:16:09 -0500] "GET /index.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42 HTTP/1.1" 200 2146

Sometimes 2 request will hit one server and 1 the other, but 1 page refresh results to 3 requests arriving at the backend I checked the backend servers configs and they are OK

Is the haproxy config wrong? Thanks

share|improve this question
    
Is it possible these requests you see are just multiple HTTP requests to load the page? I believe the roundrobin balance will have each separate request go to a different backend server. If you wanted a user to only interact with a single backend server at a time, I think you'd need to look into persistence. As another possibility, could you be seeing the backend server checks in the logs? –  Paul Kroon Jan 24 '13 at 19:02
    
Hi. I have ruled out all of the above. The page I request is just a phpinfo(). Nothing else. Additionally, the instant I refresh the browser I see the 3 requests, so it cannot be from any checks –  Thomas Jan 24 '13 at 20:42
    
Paul you were right. The phpinfo() was making 3 requests actually. Sometimes your mind gets stuck in the simplest things. Thanks for the help and sorry –  Thomas Jan 25 '13 at 8:57
    
No problem, I'm glad it was an easy one. I added my comment as an answer if you want to mark it to close this out. –  Paul Kroon Jan 25 '13 at 13:51
    
Thomas, Does your config work for both 80 & 443 I am trying to figure out how to get my Load Balancers to support SSL and nonSSL traffic –  Ehask Apr 3 '13 at 0:49

1 Answer 1

up vote 1 down vote accepted

Is it possible these requests you see are just multiple HTTP requests to load the page? I believe the roundrobin balance will have each separate request go to a different backend server. If you wanted a user to only interact with a single backend server at a time, I think you'd need to look into persistence. As another possibility, could you be seeing the backend server checks in the logs?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.