On Nov 23, 2016 20:16, "Jonathan Opperman" <[email protected]> wrote:

>> my.site.example.net/example.com -> my-site-example-net.example com
>
>
> This, is this do-able? It will be different domains, and different level
sub domains
> but they will utimately end up with using *.example.com *.example2.com
> certificates that terminate on the haproxy server.
>
> http://my.site.example.com/example.com --> http://my-site.example.com
> http://my.other.site.example.com/example.com -->
http://my-other-site.example.com

This can also be done, though it's a little trickier, because you'd need to
match with path_beg or path_reg and then munge the uri with regsub to
remove that and potentially the initial leading slash along with the host
header parts.

> Thanks for this, i've tested and mine for some reason looks like the one
you suggest
> on the other hand:
>
> * Rebuilt URL to: www.test.1.example.com/

> < Location: https://www-test-1-example.com.example.com/

Take a look at my setup again.

http-request redirect location https://
%[hdr(host),regsub(\.example\.com$,),regsub(\.,-,g)].example.com%[capture.req.uri]
if { hdr_reg(host) -i .+\..+\.example\.com$ }

I believe your problem is here:

hdr(host),regsub(\.example\.com$,)

This first regsub needs to match .example.com at the end of the original
host header, and strip it out completely by replacing it with the empty
string that is hiding between , and ) at the end.

If it doesn't match correctly, it would leave the .example.com in place and
fail in much the way your output illustrates.

Reply via email to