0

I am running my Kestrel servers behind an IIS Reverse Proxy (.NET Core 1.0.0). It works great, except, certain cases - such as being redirected to a login page upon failed access - results in the user being sent to http://localhost:8080/Account/Login (the address that Kestrel is bound to) instead of http://www.example.net/Account/Login (the reverse proxy address).

I know that I can configure IdentityOptions in Startup.cs, which also includes the ability to set LoginPath, like:

services.Configure<IdentityOptions>(options =>
{
    options.Cookies.ApplicationCookie.ExpireTimeSpan = TimeSpan.FromDays(1);
    options.Cookies.ApplicationCookie.SlidingExpiration = true;
    options.Cookies.ApplicationCookie.LoginPath = PathString("/Admin/Login");
});

Unfortunately, I cannot set an absolute path.

I also looked into the possibility to inspect and rewrite the URL per this response, but I feel like this may not be the right way to go, though I don't have any direct reason as to why.

app.Use(async (context, next) =>
{
    var baseUri = Configuration["Site:BaseUri"];
    if (baseUri.Contains(context.Request.Host.ToString()))
    {
        await next();
    }
    else
    {
        var newUri = $"{context.Request.Scheme}://{baseUri}{context.Request.Pat‌​h}{context.Request.Q‌​ueryString}";
        context.Response.Redirect(newUri);
    }
});

On top of all of this, I did find this link from the FunnelWeb project which basically looks like what I am wanting to do (although, for an older version of ASP.NET).

I would appreciate any guidance to point me in the right direction.

Community
  • 1
  • 1
JasCav
  • 34,458
  • 20
  • 113
  • 170
  • How you tested that it is not redirected to example.net ? Means How you hosted site ? Local IIS or some other way. – dotnetstep Aug 26 '16 at 05:40
  • How do you setup port in your Startup.cs file? Do you use the IIS integration option? –  Aug 26 '16 at 08:02

0 Answers0