Use a file as backup for maintenance

Hi, I’m migrating from Netscaler to HAproxy and I have to set a simple html page as maintenance page when all the non-backup servers are down.

Now, instead of spinning up a new webserver just to be used as backup, can I use instead a static page in (like /etc/haproxy/static/maintenance.html)?

Refer to http-request return:

This works for small files only (see the documentation).

I don’t think it fits well with my case, and reading my OP I think it was not clear.
I’d like to add a backup server in my backend, to be used as last resource.

server web01 check
server web02 check
server web03 check backup

But in this case I would need a simple web server only for a “stupid” maintenance page.
Can’t I just use a file as a server?

No, that is not possible.

You would use http-request return togetheter with a nbsrv condition, so that it shows when both servers are down.

frontend www
 http-request return file /home/user/maintenancefile if { nbsrv(backendname) eq 0 }
1 Like

Very clever, thank you!
I had to modify it in this way:

http-request return content-type text/html file /home/user/maintenancefile if { nbsrv(backendname) eq 0 }
1 Like