HAProxy community

Add a string into an uri


#1

Hi guys,

I’m trying to add a string into an uri. Like this:

Original URI: abc.acme.com

New URI: xyz.abc.acme.com

So, the user will type the first one but the server will receive the second one (For configuration reasons I need to receive this address on the server side)

I tried the bellow config but it does not work.

reqirep ^ Host: \ abc.acme.com Host: \ xyz.abc.acme.com

Can you help me?

Thanks in advance!
Renato Souza


#2

You have some invalid spaces in there, this needs to be:

reqirep ^Host:\ abc.acme.com Host:\ xyz.abc.acme.com

Only 4 space characters, after reqirep, twice directly after Host:\ and between the old domain name and the new Host:\ header.


#3

When I do that, the curl result shows host with abc.acme.com and location with xyz.acme.com.br (As you can see in the quote bellow). Is that the expected behavior? Because now I have a new error message: Invalid CORS request

GET / HTTP/1.1
User-Agent: curl/7.29.0
Host: abc.acme.com
Accept: /

< HTTP/1.1 302 Found
< Date: Thu, 29 Nov 2018 19:56:30 GMT
< Server: Apache/2.4
< Location: https://xyz.abc.acme.com/SASDrive/
< Content-Length: 237
< Connection: close
< Content-Type: text/html; charset=iso-8859-1

I believe that my apache server needs the URI in the host field (But i dont have certainty :thinking:)


#4

That means rewriting the Host header works.

Of course, specific CORS policies may cause trouble now, if the domain does not match. You will have to dig into the specific CORS settings to understand how to adjust it for your use-case.

No. The URI doesn’t belong in the Host header.


#5

Thanks Lukas!

I´ll look for specific CORS settings.