Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforcing SSL topic: HTTPS_PORT env var details #7767

Merged
merged 6 commits into from
Jul 30, 2018
Merged

Conversation

guardrex
Copy link
Collaborator

Fixes #7659

More to come on remarks about env vars across the repo when I get to the Configuration coverage issue (#7102).

I think we're going to have to go in this direction wherever we mention env vars explicitly because we probably won't be able to rely on prior knowledge when they're mentioned outside of config/hosting. I'll analyze the situation further later this week or early next week. For now, this will fix this one spot.

@guardrex guardrex requested a review from Tratcher July 23, 2018 19:07
@guardrex guardrex mentioned this pull request Jul 23, 2018
8 tasks
@guardrex guardrex closed this Jul 23, 2018
@guardrex guardrex reopened this Jul 23, 2018
@Tratcher
Copy link
Member

FYI I'm out at an event most of the week, I'll catch up on these later in the week.

@guardrex guardrex closed this Jul 24, 2018
@guardrex guardrex reopened this Jul 24, 2018
* `ASPNETCORE_HTTPS_PORT` environment variable.
* `ASPNETCORE_HTTPS_PORT` environment variable when the app relies on either of the following host configuration approaches. Otherwise, the port is configured by setting the `HTTPS_PORT` environment variable.
- The app runs on the [Web Host](xref:fundamentals/host/web-host).
- The app uses the environment variable configuration provider ([AddEnvironmentVariables(IConfigurationBuilder, String)](/dotnet/api/microsoft.extensions.configuration.environmentvariablesextensions.addenvironmentvariables#Microsoft_Extensions_Configuration_EnvironmentVariablesExtensions_AddEnvironmentVariables_Microsoft_Extensions_Configuration_IConfigurationBuilder_System_String_)) with a prefix of `ASPNETCORE_`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the pattern from Hosting?
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/web-host?view=aspnetcore-2.1#host-configuration-values
This is the same kind of config value, we only recommend providing it as an environment variable.

Copy link
Collaborator Author

@guardrex guardrex Jul 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The key seems to break with tradition ... I was expecting httpsPort.

It should be added over in the host configuration of Web Host, mentioned in the Enforcing HTTPS topic, and linked over.

Web Host

**Key**: https_port
**Type**: *string*
**Default**: 443
**Set using**: `UseSetting`
**Environment variable**: `ASPNETCORE_HTTPS_PORT`

```csharp
WebHost.CreateDefaultBuilder(args)
.UseSetting("https_port", "8080")
```

Generic Host

No bearing ... no web workloads (at this time).

@guardrex
Copy link
Collaborator Author

guardrex commented Jul 28, 2018

@Tratcher Ok ... try it now.

[EDIT]

we only recommend providing it as an environment variable.

Let me know if it should say that explicitly.

Copy link
Member

@Tratcher Tratcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also update the earlier line "Uses the default HttpsRedirectionOptions.HttpsPort (443)."? There was a last minute design change where the default was removed, the middleware only activates if a port is explicitly set via options or config, or discovered from the local server.

We were having trouble with sites redirecting to 443 when they didn't have that port configured yet.


### HTTPS Port

Set the HTTPS port. Used in [enforcing HTTPS](xref:security/enforcing-ssl).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set the HTTPS redirect port.


**Key**: https_port
**Type**: *string*
**Default**: 443
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No default

* [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**: 443
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one too

@guardrex guardrex merged commit de5ec78 into master Jul 30, 2018
@guardrex guardrex deleted the guardrex-patch-1 branch July 30, 2018 18:40
@guardrex guardrex mentioned this pull request Jul 30, 2018
32 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting ASPNETCORE_HTTPS_PORT does not work
2 participants