diff --git a/aspnetcore/fundamentals/host/web-host.md b/aspnetcore/fundamentals/host/web-host.md index 5da5c9f763..1582a775cd 100644 --- a/aspnetcore/fundamentals/host/web-host.md +++ b/aspnetcore/fundamentals/host/web-host.md @@ -318,6 +318,25 @@ WebHost.CreateDefaultBuilder(args) ::: moniker-end +::: moniker range=">= aspnetcore-2.1" + +### HTTPS Port + +Set the HTTPS redirect port. Used in [enforcing HTTPS](xref:security/enforcing-ssl). + +**Key**: https_port +**Type**: *string* +**Default**: A default value isn't set. +**Set using**: `UseSetting` +**Environment variable**: `ASPNETCORE_HTTPS_PORT` + +```csharp +WebHost.CreateDefaultBuilder(args) + .UseSetting("https_port", "8080") +``` + +::: moniker-end + ::: moniker range=">= aspnetcore-2.0" ### Prefer Hosting URLs diff --git a/aspnetcore/security/enforcing-ssl.md b/aspnetcore/security/enforcing-ssl.md index 3620220f97..0aa603a171 100644 --- a/aspnetcore/security/enforcing-ssl.md +++ b/aspnetcore/security/enforcing-ssl.md @@ -58,11 +58,18 @@ The following mechanisms set the port automatically: > [!NOTE] > When an app is run behind a reverse proxy (for example, IIS, IIS Express), `IServerAddressesFeature` isn't available. The port must be manually configured. When the port isn't set, requests aren't redirected. -The port can be configured by setting the: +The port can be configured by setting the [https_port Web Host configuration setting](xref:fundamentals/host/web-host#https-port): -* `ASPNETCORE_HTTPS_PORT` environment variable. -* `http_port` host configuration key (for example, via *hostsettings.json* or a command line argument). -* [HttpsRedirectionOptions.HttpsPort](/dotnet/api/microsoft.aspnetcore.httpspolicy.httpsredirectionoptions.httpsport). See the preceding example that shows how to set the port to 5001. +**Key**: https_port +**Type**: *string* +**Default**: A default value isn't set. +**Set using**: `UseSetting` +**Environment variable**: `HTTPS_PORT` (The prefix is `ASPNETCORE_` when using the Web Host.) + +```csharp +WebHost.CreateDefaultBuilder(args) + .UseSetting("https_port", "8080") +``` > [!NOTE] > The port can be configured indirectly by setting the URL with the `ASPNETCORE_URLS` environment variable. The environment variable configures the server, and then the middleware indirectly discovers the HTTPS port via `IServerAddressesFeature`.