Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4718

Redirect www. to non www. not working

$
0
0

@chomps wrote:

Hi,

I have quite an advanced HAP v1.5 config going but can't seem to get to strip away www. from all http requests. I have multiple sub domains all under a wildcard cert and I can not have any www. The structure is as follows:
abc.example.com
def.example.com
ghi.example.com
... etc

This does go on to the ssl part afterwards. This is what I have to strip away any www. first:

http-request add-header X-Host-Redirect yes if { hdr_beg(host) -i www. }
acl host_redirect hdr_cnt(X-Host-Redirect) eq 1
reqirep ^Host:\ www.(.*)$ Host:\ \1 if host_redirect
redirect code 301 scheme http if host_redirect

Then it goes on to the ssl as follows:

frontend 192-168-0-18-80 192.168.0.18:80
redirect scheme https code 301 if { hdr(Host) -i abc.example.com } !{ ssl_fc }
redirect scheme https code 301 if { hdr(Host) -i def.example.com } !{ ssl_fc }
redirect scheme https code 301 if { hdr(Host) -i ghi.example.com } !{ ssl_fc }
....etc

then the acl's and backends.

Could someone please help me understand why I just get a 503 error if I use www.abc.example.com
Thanx in advance.

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4718

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>