3
votes

I am transitioning my ASP.Net web site to Azure hosting. I am using an application gateway with SSL offload, so my individual load balanced web servers do not have the SSL cert installed. Since SSL is handled on the application gateway, how do I require SSL from the client and redirect from HTTP to HTTPS?

2

2 Answers

4
votes

I do this with close to 300 sites running though 3 separate application gateways, once you get it configured, it works well.

The answer lies in the configuration of the Listener/Rule pairs.

You will need two Listeners (one for HTTP, and one for HTTPS) and two Rules (again one for HTTP, and one for HTTPS) for each site to achieve this.

Here it is laid out step by step for you:

1. Create a new HTTP Listener: Give it a name like 'Listener_HTTP', Port 80, HTTP Protocol, Multi site listener type, put in your host name like so:

enter image description here

2. Create a new HTTPS Listener: Name 'Listener_HTTPS, Port 443, HTTPS Protocol, either choose an existing, or create a new SSL cert, Multi site listener type, put in your host name like so:

enter image description here

3. Create a new HTTP Rule: Create a new Rule, name 'Rule_HTTP'. On the 'Listener tab, link it to the HTTP listener created in Step 1 above like so:

enter image description here

On the 'Backend Targets' tab, the Target Type should be 'Redirection', redirection type should be 'Found', and redirection target should be your HTTPS listener created in Step 2 above as follows:

enter image description here

4. Create a new HTTPS Rule: Create a new rule, name 'Rule_HTTPS', on the 'Listener' tab point it at the HTTPS Listener created in Step 2 above, as follows:

enter image description here

On the 'Backend Targets' tab, Set Target type to 'Backend Pool' and point it at your chosen Backend Pool and HTTP settings as follows (this answer assumes you already have those setup):

enter image description here

An voila! There you have it! Any requests that hit HTTPS directly will go straight through to the backend pool. Any that hit HTTP, will get looped back to the HTTPS Listener effectively achieving the forced redirection you are looking for.

0
votes

Don't know if this will help or not. https://docs.microsoft.com/en-us/azure/application-gateway/application-gateway-ssl-portal

If you are moving to web apps instead of vms, you will probably need to configure for end to end ssl.