Original URL getting changed for similar DNS entries Exchange OWA

I’m running an Exchange 2013 on-prem environment through HAPROXY (1.8.16) and recently discovered an issue where I have multiple URLs pointing to one VIP on the load balancer (centos7). For example:

email.cloud.domain.com
email.domain.com
webmail.domain.com

all point to 10.1.2.25

As a client, if I navigate to email.cloud.domain.com - haproxy initially sees my request but somewhere it gets re-written to email.domain.com. This only happens when a client is talking directly to the haproxy lb IP. Externally the traffic goes via a firewall and this behavior does not occur. What configuration could be causing this?

Additional info: I originally thought this was only happening for similar DNS entries into one VIP, but this isn’t the case.

navigating to email.siteb.domain.com/owa also redirects to email.domain.com - which is an entirely different VIP on a different loadbalancer. Navigating to mail.domain.com (a legacy OWA url navigates normally and does not revert back to email.domain.com). Is this simply explained anywhere and where should I look in my config for this to be happening? I don’t believe this is an exchange issue as it only happens internally with clients directly to the LB.

You may want to capture the Location header and check in the logs all the 301 / 302 status codes.
My bet is that your exchange is not properly configured or it thinks your HAProxy IP address is not “trusted”.

As Baptiste said might be something with your configuration ,or something to do with your exchange urls.

Paul’s script is an excellent tool. Could you please check the results of GetExchangeURLs.ps1.

Are you doing any DNS aliasing , like email.cloud.domain.com has a CNAME for email.domain.com ?

edit:
Do you have multiple exchange server on the different domains ? or just a single/dag/cluster one serving all the requests ?