Service unavailable HTTP error 503 : the service is unavailable
I get the following errors in the log file :
Server1 harpoxy[6324] publicip https~ backend/destinationserver1 0/0/0/1/1 503 513 1/1/0/0/0 0/0 adfsname GET adfs/ls/idpinitiatedsignon.aspx HTTP /1.1
The problem is more with the ADFS system than with haproxy. ADFS 3.0 (not sure about previous versions) will only react to requests that contain the correct SNI header. Haproxy however does not send it in the configuration you’ve provided.
Switch to TCP backend, this way the whole SNI stuff will be worked around, however SSL will not be terminated on the haproxy
Change the ADFS binding through the commands provided in the blockpost so it does react to ALL requests that come to 443, not only those that contain the appropriate SNI header
Change the haproxy configuration so it does include the the SNI header when requests are sent to the backend. Something like sni str(sni.domain.tld) in the server line will do. Beaware: Health checks are to my knowledge not SNI compatible. Meaning you cannot do http health checks as they miss the sni header. you can switch back to just checking for tcp port 443 being alive.
On HAproxy 1.7 we usually use this external health check for ADFS 3.0:
#!/bin/bash
# Script to check SNI enabled servers are healthy
# $3 contains the IP address of the real server and is passed by the
# calling program (HAProxy)
REAL_SERVER_IP=$3
SNI_HOST="adfs.test.com"
SNI_URI="adfs/ls/idpinitiatedsignon.htm"
CHECK_VALUE="Sign in"
# check if previous instance of health check is running & kill if req'd
PIDFILE="/var/run/sni-check-$SNI_HOST.pid"
if [ -f $PIDFILE ]
then
kill -9 `cat $PIDFILE` > /dev/null 2>&1
fi
# write the process ID to the PID file
echo "$$" > $PIDFILE
# check that the ADFS login page is accessible
CURL_OUTPUT=$(/usr/bin/curl -k -m 5 --resolve \
$SNI_HOST:443:$REAL_SERVER_IP \
https://$SNI_HOST/$SNI_URI)
if [[ $CURL_OUTPUT == *$CHECK_VALUE* ]]
then
exit 0
else
exit 1
fi