redirect base URL Azure网站到自定义域

问题描述 投票:0回答:1

我们在使用本地自定义域的Azure网站上托管了Promise应用程序。它大部分时间都可以在自定义域上工作,但是当会话过期时,它将重定向到Azure网站。

由于该应用程序已对接并托管在Linux Web应用程序上,因此

web.config

重写规则对我不起作用。
I尝试使用.NET Core中间件,但是Regex仅处理相对路径,因此无法检查基本URL是否包含

azurewebsite

,因此在这种情况下我不能重定向。

var rewrite = new RewriteOptions()
                .AddRedirect("the regex here check only relative path !!", "custom.domain");
app.UseRewriter(rewrite);

我也尝试了此启动时,“重定向太多”错误
app.Use(async (context, next) =>
{
    var url = context.Request.Host.Value;

    if (url.Contains("azurewebsites"))
    {
            context.Response.Redirect("https://custom.domain");
            return;
    }

    await next();
});

对此主题的任何帮助都将不胜感激。
谢谢你
    

Application Gateway在将请求转发到后端之前将六个额外的标头插入所有请求。这些标头是X-Forward-For,X-Forward-port,X-Forwarded Proto,X-Original-Host,X-Original-url和X-AppGW-Trace-ID。 X-Foriginal-主机标头包含请求到达的原始主机标头。该标头在Azure网站集成中很有用,在该网站集成中,在将流量路由到后端之前,对传入的主机标头进行了修改。如果启用了会话亲和力作为选项,则添加了一个由网关管理的亲和力cookie。 有关更多信息,请参阅此链接:

Https://learn.microsoft.com/en-us/azure/application-gateway/how-application-gateway-works-works#modifications-to-the-request

c# asp.net-core http-redirect url-rewrite-module
1个回答
0
投票

app.Use(async (context, next) => { if (context.Request.Headers.GetValues("X-Original-Host") != null) { var originalHost = context.Request.Headers.GetValues("X-Original-Host").FirstOrDefault(); context.Request.Headers.Set("Host", originalHost); } await next.Invoke(); });

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.