diff --git a/src/Owin.Security.Providers.LinkedIn/LinkedInAuthenticationHandler.cs b/src/Owin.Security.Providers.LinkedIn/LinkedInAuthenticationHandler.cs
index 2229472..d13d601 100644
--- a/src/Owin.Security.Providers.LinkedIn/LinkedInAuthenticationHandler.cs
+++ b/src/Owin.Security.Providers.LinkedIn/LinkedInAuthenticationHandler.cs
@@ -61,7 +61,7 @@ namespace Owin.Security.Providers.LinkedIn
return new AuthenticationTicket(null, properties);
}
- var requestPrefix = Request.Scheme + "://" + Request.Host;
+ var requestPrefix = Request.Scheme + "://" + this.GetHostName();
var redirectUri = requestPrefix + Request.PathBase + Options.CallbackPath;
// Build up the body for the token request
@@ -173,7 +173,7 @@ namespace Owin.Security.Providers.LinkedIn
var baseUri =
Request.Scheme +
Uri.SchemeDelimiter +
- Request.Host +
+ this.GetHostName() +
Request.PathBase;
var currentUri =
@@ -271,5 +271,15 @@ namespace Owin.Security.Providers.LinkedIn
return context.IsRequestCompleted;
}
+
+ ///
+ /// Gets proxy host name from if it is set.
+ /// If proxy host name is not set, gets application request host name.
+ ///
+ /// Host name.
+ private string GetHostName()
+ {
+ return string.IsNullOrWhiteSpace(Options.ProxyHost) ? Request.Host.ToString() : Options.ProxyHost;
+ }
}
}
\ No newline at end of file
diff --git a/src/Owin.Security.Providers.LinkedIn/LinkedInAuthenticationOptions.cs b/src/Owin.Security.Providers.LinkedIn/LinkedInAuthenticationOptions.cs
index 02aa95c..77cbc1d 100644
--- a/src/Owin.Security.Providers.LinkedIn/LinkedInAuthenticationOptions.cs
+++ b/src/Owin.Security.Providers.LinkedIn/LinkedInAuthenticationOptions.cs
@@ -43,6 +43,16 @@ namespace Owin.Security.Providers.LinkedIn
///
public PathString CallbackPath { get; set; }
+ ///
+ /// Gets or sets the middleware host name.
+ /// The middleware processes the on this host name instead of the application's request host.
+ /// If this is not set, the application's request host will be used.
+ ///
+ ///
+ /// Use this property when running behind a proxy.
+ ///
+ public string ProxyHost { get; set; }
+
///
/// Get or sets the text that the user can display on a sign in user interface.
///