Base solution for your next web application
Open Closed

Azure Application Gateway - Redirecting to private DNS not public host name #9800


User avatar
0
CrayonGroupSCA created

7.2 MVC + jQuery on .net Core

We are trying out our platform behind an Azure Application Gateway running on an Azure App Service. The public DNS would be something like https://public.domain.com but when trying to log in to "/App/SomeController" the user gets redirected to "https://private.azurewebsites.net/Account/Login?ReturnUrl=/App/SomeController" which is the private DNS behind the gateway.

The "private.azurewebsites.net" does not exist in any appsetting so it looks like it is being picked up by the HttpContext.

Do you know how this can be overridden? As it looks to be handled in the Abp code rather than Zero.

Thanks, Dave


6 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You cna take a look at https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-3.1. If you use forwarded headers, your app should get correct HOST from the HttpContext.

  • User Avatar
    0
    CrayonGroupSCA created

    Thanks, I hadn't seen that before so we will investigate. I'll update this post with the end result in case anyone else needs to know in the future.

  • User Avatar
    0
    CrayonGroupSCA created

    The middleware change didn't work for us so we will now look into something on the Azure Application Gateway instead, based on this: https://docs.microsoft.com/en-us/azure/application-gateway/rewrite-http-headers#modify-a-redirection-url

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @CrayonGroupSCA

    There are some other criterias for header forwarding of ASP.NET Core. However, you can simply write a middleware like below and set it yourself;

    app.Use((httpContext, next) =>
    {
        httpContext.Request.Scheme = "https";
        return next();
    });
    
  • User Avatar
    0
    CrayonGroupSCA created

    Thanks for that suggestion, have tried it out and its working on our Test / Staging servers which have a static url so we know where to change the context to. Hopefully next week can try it out on our mock production site to see how it works with the Tenancy name in the url.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @CrayonGroupSCA

    Great :). Please let us know if you face any other problems.