Backend by dns and not by ip



I have 2 servers: server_1 and server_2 where server_2 is a virtual machine that to access it I have to access by because if I use the ip I will be accessing the main machine.

I have configured that server_1 uses the ip and server_2 use the option redir.

server server_1 check
server server_2 check redir

Now I have a problem, when using server_2 my application gives problems with Access-Control-Allow-Origin. From what I’ve added in the frontend
http-response add-header Access-Control-Allow-Origin% [capture.req.hdr (0)] if {capture.req.hdr (0) -m found}

But when you add that line, it gives problems to my server_1, since Access-Control-Allow-Origin is duplicated

How can I configure that when accessing server_1, do not add Access-Control-Allow-Origin and when you access server_2, add it?

Or how can I do to not use the redirect option and when using server_2 use the domain name and not its ip?


Thats not at all what the redir option is for. The redir option is causing a redirect to, however what you seem to need is to rewrite the Host header.

In the backend, set the Host header. server_1 does not care and server_2 will expect it:
http-request set-header Host