I have a WordPress website running on haproxy server with round-robin
between two servers that run httpd and MySQL replication

I found problems occur while using haproxy without setting persistence
connection in WordPress media gallery while uploading pictures or
change the view grid for a specific album. I am trying to find out if
there a possible way to set a cookie for specific URL which likely
will be wp-admin path and the rest of the website for the visitors
will be round-robin method without persistence connections for more
load balancing efficiency

My current haproxy configuration are

global
    log 127.0.0.1    local0
    log 127.0.0.1    local1 notice
    tune.ssl.default-dh-param 1024
    maxconn 4096
    user haproxy
    group haproxy
    daemon

defaults
    log    global
    mode    http
    option    httplog
    option    dontlognull
    option forwardfor
    option http-server-close
    timeout http-request    30s
    timeout queue           1m
    timeout connect         30s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 0s
    timeout check           30s

#---------------------------------------------------------------------
# HAPROXY STATS
#---------------------------------------------------------------------

listen webfarm 192.168.1.2:80
       mode http
       stats enable
       stats uri /haproxy?stats
       stats realm Haproxy\ Statistics
       stats auth sawa4:SDLJHi23ouy

#---------------------------------------------------------------------
# WEBSERVER
#---------------------------------------------------------------------

frontend https-in
    bind *:443 transparent ssl crt /etc/ssl/private/website.pem
    #reqadd X-Forwarded-Proto:\ https
    default_backend https-backend

backend https-backend
    balance roundrobin
    option httpclose
    option forwardfor
    cookie website.com insert indirect nocache

    #enter the IP of your application here
    server web01 192.168.1.2:443 maxconn 1024 check ssl verify none
    server web02 192.168.1.3:443 maxconn 1024 check ssl verify none

My question is how can i enable cookie for any URL that includes wp-admin regex?

Reply via email to