log /dev/log    local0
log /dev/log    local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy

# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private

# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL). This list is from:
#  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
ssl-default-bind-options no-sslv3

log global
mode    http
option  httplog
option  dontlognull
    timeout connect 5000
    timeout client  50000
    timeout server  50000
    option redispatch
   errorfile 400 /etc/haproxy/errors/400.http
   errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http

# Back-end definition.

listen appname testingcart.co.uk:80
    mode http
    stats enable
    stats uri /haproxy?stats
    balance source
    option httpclose
    option forwardfor

    cookie PHPSESSID prefix
    cookie SERVERID insert indirect nocache

    server web1 ip.address1:80 check cookie s2
    server web2 ip.address3:80 check cookie s3
        server web3 ip.address2:80 check cookie s4

Suppose this is my initial configuration. I heard by default HAProxy does not cache contents. How do I enable it without using Varnish.

  • 1
    I'm voting to close this question as off-topic because just because all you have is a hammer, does not make everything a nail.
    – womble
    Jun 1, 2016 at 2:47

1 Answer 1


don't use the wrong tool

is a wonderful tool. It does not provide caching. A quick scan of the fine docs can verify this. Unless you want to patch haproxy you need to use a tool that does what you're looking to do.

don't create impossible problems

By asking for haproxy to do something that it doesn't and excluding the tool that seems to do what you want to do you've create an impossible situation. There is no technical solution for this. Don't make choices that box you into a corner.

try varnish or anything that actually caches

If you get over that you might find this tutorial on using varnish with haproxy useful or try varnish by itself. Maybe squid or memcached would be more your speed.


Not the answer you're looking for? Browse other questions tagged .