I've got a Layer 7 Load Balancer setup using HAProxy for WordPress Multisite.
I'm looking to have anything related to the WordPress backend to be served from a specific group of servers (A/K/A anything in
/wp-admin/) while serving the frontend of the WordPress websites from another group of servers.
Do I need to adjust something in
wp-config.php to change cookie names so that they include the server ID? or check for the server ID in the WordPress cookie? I feel like problems #1 and #2 are cookie related. I have no idea why #3 is happening. My servers aren't lagging at all, and should be responding plenty fast.
With my current configuration I'm facing a few problems here:
It does indeed appear to be connecting me to the appropriate admin server. However, after a while in the dashboard. The WordPress login form pops up asking me to re-login again.
Most admin pages work just fine however once in a while, again, same as #1, the WordPress login for pops up and asks me to login again.
Every now in then I get a "504 Gateway Time-out - The server didn't respond in time."
Here's what my configuration looks like:
defaults log global mode http option httplog option dontlognull 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 retries 3 option redispatch maxconn 2000 timeout connect 5000 timeout check 5000 timeout client 30000 timeout server 30000 frontend http-in bind *:80 option httplog option http-server-close acl has_domain hdr(host) -m found acl has_www hdr_beg(host) -i www. use_backend live_servers if has_domain has_www acl has_admin path_beg /wp-admin acl has_login path_beg /wp-login.php acl has_custom_login path_beg /manage use_backend admin_servers if has_admin or has_login or has_custom_login default_backend live_servers backend live_servers mode http stats enable stats uri /haproxy?stats balance roundrobin option httpclose option forwardfor cookie SERVERID insert indirect nocache server s1 22.214.171.124:80 check cookie s1 server s2 126.96.36.199:80 check cookie s2 backend admin_servers mode http stats enable stats uri /haproxy?stats balance roundrobin option httpclose option forwardfor cookie SERVERID insert indirect nocache server s1 188.8.131.52:80 check cookie s1
I'm willing to provide a pretty hefty bounty for this. If there's any settings which I'm missing or you think you could improve upon my configuration, please provide a full configuration including all appropriate settings in your answer.
Edit: I am currently using HAProxy 1.6.x and willing to upgrade to latest version if that's what it takes to get a valid solution.