I have 2 backend one for api and one for admin each has its own ACL that get matched and sends the request to the proper backend, the problem is I want any other url that doesnt fall under those ACLs to get http 404, the apps do not cover this so is there a way to do it in HAproxy ?
1 Like
You can create a new backend without any server (which will cause a 503 error), and use a custom 503 errorfile for this, generating the 404 error (custom error files include HTTP response and header, not just payload).
For example:
frontend www-in
default_backend generate_404
backend generate_404
errorfile 503 /etc/haproxy/generate_404.http
Than create that file as per errorfile docs.
2 Likes