HAProxy community

Haproxy http code

Hello

My config haproxy.cfg

frontend sait
bind *:7030

acl hdr_sait            hdr_beg(host)   -i sait.ru
acl status_404 status 404
http-response set-header Location https://sait.ru/ErrorPages/404_ru.html if status_404
http-response set-status 302 if status_404

acl status_5xx status 500 502 503 504
http-response set-header Location https://sait.ru/ErrorPages/503.html if status_5xx
http-response set-status 302 if status_5xx

acl path_4 path_beg /ErrorPages/
use_backend bknd_nginx if hdr_sait path_4
use_backend bknd_tomcat if hdr_sait

how can I make sure that the correct http codes 404, 503,500 are given to a higher-standing server. And not 302 ?

I’ve been here so that only nginx does this, but the config test shows warning

frontend sait
bind *:7030

acl hdr_sait            hdr_beg(host)   -i sait.ru
acl status_404 status 404
acl status_5xx status 500 502 503 504

use_backend bknd_nginx if hdr_sait status_404
use_backend bknd_nginx if hdr_sait status_5xx
use_backend bknd_tomcat if hdr_sait

acl ‘status_404’ will never match because it only involves keywords that are incompatible with ‘frontend use-backend rule’

use_backend is a client->server feature and status is a fetch which works on the way server->client.
In other terms, you can’t use a “response phase” feature at request time

Are there any ways to change 302 to 404?