Thanks for your help so far, I’ve setup the config on a new system so just this host is configured for testing:
$ haproxy -vv
HA-Proxy version 1.7.8 2017/07/07
Copyright 2000-2017 Willy Tarreau willy@haproxy.org
Build options :
TARGET = linux2628
CPU = generic
CC = gcc
CFLAGS = -O2 -g -fno-strict-aliasing -Wdeclaration-after-statement -fwrapv
OPTIONS =
Default settings :
maxconn = 2000, bufsize = 16384, maxrewrite = 1024, maxpollevents = 200
Encrypted password support via crypt(3): yes
Built without compression support (neither USE_ZLIB nor USE_SLZ are set)
Compression algorithms supported : identity(“identity”)
Built without OpenSSL support (USE_OPENSSL not set)
Built without PCRE support (using libc’s regex instead)
Built without Lua support
Built with transparent proxy support using: IP_TRANSPARENT IPV6_TRANSPARENT IP_FREEBIND
Available polling systems :
epoll : pref=300, test result OK
poll : pref=200, test result OK
select : pref=150, test result OK
Total: 3 (3 usable), will use epoll.
Available filters :
[COMP] compression
[TRACE] trace
[SPOE] spoe
The config file:
#---------------------------------------------------------------------
Global settings
#---------------------------------------------------------------------
global
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the ‘-r’ option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
# file. A line like the following can be added to
# /etc/sysconfig/syslog
#
# local2.* /var/log/haproxy.log
#
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
tune.ssl.default-dh-param 2048
# turn on stats unix socket
stats socket /var/lib/haproxy/stats
#---------------------------------------------------------------------
common defaults that all the ‘listen’ and ‘backend’ sections will
use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 30s
timeout queue 1m
timeout connect 30s
timeout client 1m
timeout server 1m
timeout http-keep-alive 30s
timeout check 30s
maxconn 3000
frontend localnodes
bind *:80
mode http
option forwardfor except 127.0.0.0/8
capture request header host len 35
capture request header X-Forwarded-For len 50
capture request header Front-End-HTTPS len 50
capture request header User-agent len 225
http-request redirect code 301 location http://%[hdr(host)]%[url,regsub(/$,)] if { hdr(host) -i www.example.com } { path_end / } { path_len gt 1 }
acl examplecom hdr(host) -i www.example.com
use_backend examplecom if examplecom
backend examplecom
balance leastconn
option httpclose
option forwardfor
http-request add-header X-CLIENT-IP %[src]
cookie JSESSIOND prefix
server e0 192.168.16.207:6560 cookie A check
server e1 192.168.16.217:6560 cookie A check
Here are the log entries:
With the redirect commented out I can request a page with the slash or without:
Apr 9 12:46:04 localhost haproxy[1309]: 192.168.16.60:57762 [09/Apr/2018:12:46:03.902] localnodes examplecom/e0 11/0/0/301/312 200 19804 - - --NN 0/0/0/0/0 0/0 {www.example.com|||Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0} “GET /privacy-policy HTTP/1.1”
Apr 9 12:46:10 localhost haproxy[1309]: 192.168.16.60:57772 [09/Apr/2018:12:46:09.875] localnodes examplecom/e1 12/0/0/271/283 200 19804 - - --NN 0/0/0/0/0 0/0 {www.example.com|||Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0} “GET /privacy-policy/ HTTP/1.1”
with the redirect active we get a 301 to ‘/’:
Apr 9 12:49:03 localhost haproxy[1358]: 192.168.16.60:57908 [09/Apr/2018:12:49:03.583] localnodes localnodes/ 22/-1/-1/-1/22 301 106 - - LR-- 0/0/0/0/0 0/0 {www.example.com|||Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0} “GET /privacy-policy/ HTTP/1.1”
Apr 9 12:49:04 localhost haproxy[1358]: 192.168.16.60:57909 [09/Apr/2018:12:49:03.626] localnodes examplecom/e0 21/0/1/783/807 200 58964 - - --NN 0/0/0/0/0 0/0 {www.example.com|||Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0} “GET / HTTP/1.1”