Azure应用程序网关重定向不会将默认的Azure URL重写为自定义域名。

huangapple go评论49阅读模式
英文:

Azure app gateway redirection does not rewrite the default azure url to custom domain name

问题

我的网站托管在Azure应用服务上,并且已经设置了自定义域名。

假设(实际名称已隐藏),我的默认Azure应用服务URL是https://myazureexamplesite.azurewebsites.net,而我拥有的自定义域名是https://custdomain.org。

因此,在Azure应用程序网关中,我已经正确配置了后端池(Azure应用服务),监听器监听我的自定义域名,并添加了规则,表示此监听器将被定向到配置的后端池。同时,自定义域名也被指向了应用程序网关的IP地址。

意外情况:

当有人访问https://custdomain.org时,它会被重定向到https://myazureexamplesite.azurewebsites.net

在操作上是正确的,但我不希望看到URL显示为默认应用服务URL。

我想要的是相同的应用服务内容应该显示在https://custdomain.org的URL上。

出于安全考虑,我不希望直接将自定义域名指向应用服务IP,这最终可以实现我想要的结果。

我不确定为什么Azure应用程序网关会出现这种行为。我以前尝试过Azure前门(Azure Front Door)并且它完美运行。由于一些预算原因,我无法在这里使用它。我必须使用同一个应用程序网关。我不确定这是否是Azure应用程序网关的预期行为。

如果有人能帮助我理解这种情况,我将不胜感激。

谢谢。

英文:

My website is hosted through azure app service and it is given a custom domain name as well.

Let's say (actual names are hidden) my default azure app service url is https://myazureexamplesite.azurewebsites.net and the custom domain I have is https://custdomain.org

So in the azure app gateway, I have correctly configured the backend pool (azure app service), listener which listens to my custom domain and added the rule to say that this listener will be direct to the configured backend pool. Also the custom domain is directed to the app gateway's ip.

Unexpected Scenario:

So when someone hit the url https://custdomain.org it is directed to https://myazureexamplesite.azurewebsites.net

Action wise it is correct but I don't need to see the url as default app service url.

What I want is that the same app service content should be shown in the https://custdomain.org url.

Also for security purpose I don't want to direct custom domain directly to app service ip which eventually gives me the result I want.

I am not sure why this type of behavior is happening with azure app gateway. I have previously tried with azure frontdoor and it worked perfectly. For some budgeting reasons I am unable to use that in here. I have to go through the same app gateway. I am not sure whether this is the expected behavior for azure app gateway or not.

It would be a great if someone can help me to understand this scenario.

Thank you

答案1

得分: 1

当有人访问网址https://custdomain.org时,它会被重定向到https://myazureexamplesite.azurewebsites.net。如果您希望在https://custdomain.org网址上显示相同的应用服务内容,请查看下面的解决方法。

更新后端池,创建一个自定义的健康探测以配置正确的自定义域名作为其主机名,如下所示:

Azure应用程序网关重定向不会将默认的Azure URL重写为自定义域名。

在后端设置中选择 -> Https -> 使用已知的 CA 证书作为“是” -> “覆盖为新主机名”为“否” -> 选择自定义健康探测,如下所示:

Azure应用程序网关重定向不会将默认的Azure URL重写为自定义域名。

在监听器中 -> 使用 HTTPS 协议添加监听器,并使用 PFX 证书,如下所示:

Azure应用程序网关重定向不会将默认的Azure URL重写为自定义域名。

在规则类型中,选择 https 监听器,选择应用服务的后端池,并选择应用网关的 HTTP 设置以连接应用服务后端,如下所示:

Azure应用程序网关重定向不会将默认的Azure URL重写为自定义域名。

现在,当测试后端健康和使用自定义域名的 web 应用处于健康状态时,它会成功地重定向到域名,如下所示:

Azure应用程序网关重定向不会将默认的Azure URL重写为自定义域名。

参考资料

重定向到应用服务 URL - Azure 应用程序网关 | 微软学习

英文:

> when someone hit the url https://custdomain.org it is directed to https://myazureexamplesite.azurewebsites.netIf you want same app service content should be shown in the https://custdomain.org url check this below workaround

Updated backend pool with app service create custom health probe to configure correct custom domain name as its host name like below:

Azure应用程序网关重定向不会将默认的Azure URL重写为自定义域名。

In the backend setting select -> Https -> User well-known CA certificate as YES -> "Override with new hostname" to "No" -> select custom health probe like below:

Azure应用程序网关重定向不会将默认的Azure URL重写为自定义域名。

In listener -> add listener with HTTPS protocol with PFX certificates like below:

Azure应用程序网关重定向不会将默认的Azure URL重写为自定义域名。

In rule type add https listener choose Backend Pool of App Service and select HTTP settings of App Gateway to connect the App Service backend like below:

Azure应用程序网关重定向不会将默认的Azure URL重写为自定义域名。

Now, when testing the backend health and web application using the custom domain are in healthy state it redirects with domain successfully like below:

Azure应用程序网关重定向不会将默认的Azure URL重写为自定义域名。

Reference:

Redirection to App Service URL - Azure Application Gateway | Microsoft Learn

huangapple
  • 本文由 发表于 2023年6月13日 15:50:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76462738.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定