Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 93166e5

Browse files
committedFeb 17, 2022
add early draft for consolidated article AppGw and App Svc aligned to hostname best practices
1 parent 55ea04f commit 93166e5

File tree

5 files changed

+150
-12
lines changed

5 files changed

+150
-12
lines changed
 

‎articles/application-gateway/configuration-http-settings.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: application-gateway
55
author: vhorne
66
ms.service: application-gateway
77
ms.topic: conceptual
8-
ms.date: 09/09/2020
8+
ms.date: 02/17/2022
99
ms.author: surmb
1010
---
1111

@@ -73,9 +73,6 @@ This setting lets you configure an optional custom forwarding path to use when t
7373
| /pathrule/home/secondhome/ | /pathrule/home* | /override/ | /override/secondhome/ |
7474
| /pathrule/ | /pathrule/ | /override/ | /override/ |
7575

76-
## Use for app service
77-
78-
This is a UI only shortcut that selects the two required settings for the Azure App Service back end. It enables **pick host name from back-end address**, and it creates a new custom probe if you don't have one already. (For more information, see the [Pick host name from back-end address](#pick-host-name-from-back-end-address) setting section of this article.) A new probe is created, and the probe header is picked from the back-end member's address.
7976

8077
## Use custom probe
8178

@@ -84,6 +81,18 @@ This setting associates a [custom probe](application-gateway-probe-overview.md#c
8481
> [!NOTE]
8582
> The custom probe doesn't monitor the health of the back-end pool unless the corresponding HTTP setting is explicitly associated with a listener.
8683
84+
## Configuring the host name
85+
86+
Application Gateway allows for the connection to the backend to be established using a *different* hostname than the one used by the client to connect to Application Gateway. Changing the hostname used towards the backend into a value that is different from the hostname that is used to connect to Application Gateway should however be done with care.
87+
88+
In a typical production-grade configuration, one will typically want to keep the host name used by the client towards Application Gateway the same as the hostname as used by Application Gateway towards the backend. This avoid potential issues with absolute URLs, redirect URLs and host-bound cookies.
89+
90+
Before setting up Application Gateway that deviates from this, please review the implications of such configuration as discussed in more detail in Architecture Center: [Preserve the original HTTP host name between a reverse proxy and its backend web application](/azure/architecture/best-practices/host-name-preservation)
91+
92+
There are two aspects of an HTTP setting that influence the [`Host`](https://datatracker.ietf.org/doc/html/rfc2616#section-14.23) HTTP header that is used by Application Gateway to connect to the backend:
93+
- "Pick host name from backend-address"
94+
- "Host name override"
95+
8796
## Pick host name from back-end address
8897

8998
This capability dynamically sets the *host* header in the request to the host name of the back-end pool. It uses an IP address or FQDN.
@@ -92,9 +101,9 @@ This feature helps when the domain name of the back end is different from the DN
92101

93102
An example case is multi-tenant services as the back end. An app service is a multi-tenant service that uses a shared space with a single IP address. So, an app service can only be accessed through the hostnames that are configured in the custom domain settings.
94103

95-
By default, the custom domain name is *example.azurewebsites.net*. To access your app service by using an application gateway through a hostname that's not explicitly registered in the app service or through the application gateway's FQDN, you override the hostname in the original request to the app service's hostname. To do this, enable the **pick host name from backend address** setting.
104+
By default, the custom domain name is *example.azurewebsites.net*. To access your app service by using an application gateway through a hostname that's not explicitly registered in the app service or through the application gateway's FQDN, you can override the hostname in the original request to the app service's hostname. To do this, enable the **pick host name from backend address** setting.
96105

97-
For a custom domain whose existing custom DNS name is mapped to the app service, you don't have to enable this setting.
106+
For a custom domain whose existing custom DNS name is mapped to the app service, you don't have to enable this setting. As described earlier, this is usually the preferred way of working.
98107

99108
> [!NOTE]
100109
> This setting is not required for App Service Environment, which is a dedicated deployment.
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
title: Manage traffic to App Service
3+
titleSuffix: Azure Application Gateway
4+
description: This article provides guidance on how to configure Azure App service web apps as members in backend pool on an existing or new Application Gateway.
5+
services: application-gateway
6+
author: xstof
7+
ms.service: application-gateway
8+
ms.topic: how-to
9+
ms.date: 17/02/2022
10+
ms.author: christoc
11+
---
12+
<!-- https://docs.microsoft.com/en-us/azure/application-gateway/configure-web-app-portal -->
13+
14+
# Configure App Service with Application Gateway
15+
16+
Application gateway allows you to have an App Service app or other multi-tenant service as a back-end pool member. In this article, you learn to configure an App Service app with Application Gateway. The configuration for Application Gateway will differ depending on how App Service will be accessed.
17+
18+
The first option is to have Application Gateway access App Service using it's default domain, suffixed as ".azurewebsites.net". This is the easiest configuration as it does not require a custom domain. As such it allows for a quick convenient setup. Note however that this configuration comes with limitations and that we recommend to review the implications of using different host names between the client and Application Gateway and between Application and App Service in the backend. For more information, please review the article in Architecture Center: [Preserve the original HTTP host name between a reverse proxy and its backend web application](/azure/architecture/best-practices/host-name-preservation)
19+
20+
The second option makes use of a custom domain on both Application Gateway and the App Service in the backend. This the configuration which is commonly recommended for production-grade scenarios and meets the practice of not changing the host name in the request flow. It does require however you have a custom domain (and associated certificate) available so to avoid having to rely on the default ".azurewebsites" domain.
21+
22+
23+
<!-- see example: https://github.dev/MicrosoftDocs/azure-docs/blob/main/articles/app-service/quickstart-dotnetcore.md -->
24+
<!-- markdownlint-disable MD044 -->
25+
:::zone target="docs" pivot="app-service-domainconfig-defaultdomain"
26+
<!-- markdownlint-enable MD044 -->
27+
28+
When App Service does not have a custom domain associated with it, the host header on the incoming request on the web application will need to be set to the default domain, suffixed with ".azurewebsites.net" or else the platform will not be able to properly route the request.
29+
30+
This means that the host header in the original request received by the Application Gateway will be different from the host name of the backend App Service.
31+
32+
:::zone-end
33+
34+
:::zone target="docs" pivot="app-service-domainconfig-customdomain"
35+
36+
By associating both Application Gateway and App Service in the backend pool to the same domain name, the request flow does not need to override host name and the backend web application will see the original host as was used by the client.
37+
38+
:::zone-end
39+
40+
In this article you'll learn how to:
41+
- Add App Service as backend pool to the Application Gateway
42+
- Configure the HTTP Settings for the connection to App Service
43+
44+
## Prerequisites
45+
46+
:::zone target="docs" pivot="app-service-domainconfig-defaultdomain"
47+
48+
- Application gateway: Create an application gateway without a backend pool target. For more information, see [Quickstart: Direct web traffic with Azure Application Gateway - Azure portal](quick-create-portal.md)
49+
50+
- App service: If you don't have an existing App service, see [App service documentation](../app-service/index.yml).
51+
52+
:::zone-end
53+
54+
:::zone target="docs" pivot="app-service-domainconfig-customdomain"
55+
56+
- Application Gateway: Create an application gateway without a backend pool target. For more information, see [Quickstart: Direct web traffic with Azure Application Gateway - Azure portal](quick-create-portal.md)
57+
58+
- App Service: If you don't have an existing App service, see [App service documentation](../app-service/index.yml).
59+
60+
- A custom domain name and associated certificate, stored in Key Vault. For more information on how to store certificates in Key Vault, see [Tutorial: Import a certificate in Azure Key Vault](../key-vault/certificates/tutorial-import-certificate.md)
61+
62+
:::zone-end
63+
64+
## Add App service as backend pool
65+
66+
### [Azure Portal](#tab/azp)
67+
68+
1. In the Azure portal, select your application gateway.
69+
70+
2. Under **Backend pools**, select the backend pool.
71+
72+
3. Under **Target type**, select **App Services**.
73+
74+
4. Under **Target** select your App Service.
75+
76+
:::image type="content" source="./media/configure-web-app-portal/backend-pool.png" alt-text="App service backend":::
77+
78+
> [!NOTE]
79+
> The dropdown only populates those app services which are in the same subscription as your Application Gateway. If you want to use an app service which is in a different subscription than the one in which the Application Gateway is, then instead of choosing **App Services** in the **Targets** dropdown, choose **IP address or hostname** option and enter the hostname (example.azurewebsites.net) of the app service.
80+
81+
5. Select **Save**.
82+
83+
:::zone target="docs" pivot="app-service-domainconfig-customdomain"
84+
85+
TEST - custom text for custom domain
86+
87+
:::zone-end
88+
89+
:::zone target="docs" pivot="app-service-domainconfig-defaultdomain"
90+
91+
TEST - custom text for default domain
92+
93+
:::zone-end
94+
95+
### [Powershell](#tab/powershell)
96+
97+
TODO
98+
99+
100+
## Edit HTTP settings for App Service
101+
102+
1. Under **HTTP Settings**, select the existing HTTP setting.
103+
104+
2. Under **Override with new host name**, select **Yes**.
105+
3. Under **Host name override**, select **Pick host name from backend target**.
106+
4. Select **Save**.
107+
108+
:::image type="content" source="./media/configure-web-app-portal/http-settings.png" alt-text="Pick host name from backend http settings":::
109+
110+
## Additional configuration in case of redirection to app service's relative path
111+
112+
When the app service sends a redirection response to the client to redirect to its relative path (For example, a redirect from `contoso.azurewebsites.net/path1` to `contoso.azurewebsites.net/path2`), it uses the same hostname in the location header of its response as the one in the request it received from the application gateway. So the client will make the request directly to `contoso.azurewebsites.net/path2` instead of going through the application gateway (`contoso.com/path2`). Bypassing the application gateway isn't desirable.
113+
114+
If in your use case, there are scenarios where the App service will need to send a redirection response to the client, perform the [additional steps to rewrite the location header](./troubleshoot-app-service-redirection-app-service-url.md#sample-configuration).
115+
116+
## Restrict access
117+
118+
The web apps deployed in these examples use public IP addresses that can be accessed directly from the Internet. This helps with troubleshooting when you are learning about a new feature and trying new things. But if you intend to deploy a feature into production, you'll want to add more restrictions.
119+
120+
One way you can restrict access to your web apps is to use [Azure App Service static IP restrictions](../app-service/app-service-ip-restrictions.md). For example, you can restrict the web app so that it only receives traffic from the application gateway. Use the app service IP restriction feature to list the application gateway VIP as the only address with access.
121+
122+
## Next steps
123+
124+
To learn more about the App service and other multi-tenant support with application gateway, see [multi-tenant service support with application gateway](./application-gateway-web-app-overview.md).
Loading

‎articles/application-gateway/toc.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,8 @@
248248
items:
249249
- name: Azure portal
250250
href: rewrite-url-portal.md
251-
- name: Configure App service webapp and multi-tenant service
252-
items:
253-
- name: Portal
254-
href: configure-web-app-portal.md
255-
- name: Azure PowerShell
256-
href: create-web-app.md
251+
- name: Configure App Service
252+
href: configure-web-app.md
257253
- name: Configure custom probes
258254
items:
259255
- name: Portal

‎articles/zone-pivot-groups.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,15 @@ groups:
966966
title: C#
967967
- id: programming-language-python
968968
title: Python
969+
# Owner: christoc
970+
- id: app-service-domainconfig
971+
title: Custom domain configuration
972+
prompt: Choose your domain name configuration
973+
pivots:
974+
- id: app-service-domainconfig-defaultdomain
975+
title: Default domain
976+
- id: app-service-domainconfig-customdomain
977+
title: Custom domain
969978
# Owner: jordanselig
970979
- id: app-service-cli-portal
971980
title: Experience

0 commit comments

Comments
 (0)