I have several small server and one big server that contain mirror of that several small server. Let's call it Server A, Server B, Server C and Server D for group of small server, and the big server will have Server X as name.
frontend proxy
bind 0.0.0.0:80
mode http
default_backend nodes
backend nodes
option forwardfor httpchk
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
server ServerA (server A IP):80 check
server ServerB (server B IP):80 check
server ServerC (server C IP):80 check
server ServerD (server D IP):80 check
server ServerX (server X IP):80 backup
Below is a diagram to explain my desired end result.
I want to redirect user to Server X if one of Server A to D is down/unreachable, once the server is gone up the user would have been redirected back to their corresponding server.
- John search up
www.example.com
hosted on Server B. - Haproxy redirect John to Server B.
- John is doing something on
www.example.com
on server B. - Server B is down ! John got redirected to Server X.
- John is doing something on
www.example.com
on server X. - Server B is up ! John got redirected back to server B from Server X.
Pretty sure this can be done with haproxy, but I haven't been able to find a way to do it. Anyone can shed a light to me ? I'm at complete loss now.