Enforcing SSL topic: HTTPS_PORT env var details (#7767)

pull/7881/head
Luke Latham 2018-07-30 13:39:58 -05:00 committed by GitHub
parent 0d9382d1ca
commit de5ec7818c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 4 deletions

View File

@ -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

View File

@ -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**: `<PREFIX_>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`.