0

I have a secured website (using https certificate and WAF) balanced by the Azure application gateway. The problem is that when browsing the website without www then I got the error message that this site is not secured while if I add www.domainname.com I get the secured website. I tried in the application gateway a feature called Host Type Multiple/Wildcard as in the following screenshot Multiple/Wildcard

But that did not work. So the question is: How to redirect https://domaionname.com to https://www.domainname.com

Khaled
  • 345
  • 5
  • 14

1 Answers1

1

I tried to reproduce the same in my environment and got the results successfully like below:

Once you create Application gateway and point it’s IP address to your custom domain name such as to redirect https://domaionname.com to https://www.domainname.com you can add another listener with hostname “www.example.com” and make sure that the previous listener with hostname “example.com” redirects to the newly added listener.

Try to add another listener HTTPS like below:

enter image description here

So, 2 HTTPs listeners with hostnames - one without www and one with www. Add a rule to redirect without www HTTPS listener to with www HTTPS listener.

And another rule to make sure that with www HTTPS listener is bound to a backend pool to serve the traffic like below:

Application gateway rule to redirect the listener 1 to listener 2.

enter image description here

enter image description here

I created a new rule for listener 2 to use the HTTPS settings to send traffic to my backend pool.

enter image description here

Now Application gateway for domain name redirect to https://www.domainname.com successfully like below:

enter image description here

Rukmini
  • 6,015
  • 2
  • 4
  • 14
  • Thanks for your answer but I am getting an error in Azure when creating a new listener: Failed to save configuration changes to application gateway 'my-application-gateway'. Error: Two Http Listeners of Application Gateway app-https-listener and app-https-listener2 are using the same Frontend Port – Khaled Feb 21 '23 at 13:29
  • This error usually occurs if you are public and private listener are using the same port. You shouldcreate a new Front End IP Configuration using a different port, and you can direct the traffic to the same backend port. – Rukmini Feb 22 '23 at 03:24
  • Refer this https://learn.microsoft.com/en-us/answers/questions/452279/error-when-creating-listener-on-application-gatewa?orderby=newest – Rukmini Feb 22 '23 at 03:37