Setting ASPNETCORE_HTTPS_PORT does not work
When I set ASPNETCORE_HTTPS_PORT environment variable to (eg.) 44310, the HTTPS redirection does not work. However, when I set HTTPS_PORT environment variable, the HTTPS redirection does work.
This is also stated in HttpsRedirectionOptions.HttpsPort documentation. Quoting:
/// <remarks> /// If the HttpsPort is not set, we will try to get the HttpsPort from the following: /// 1. HTTPS_PORT environment variable /// 2. IServerAddressesFeature /// 3. 443 (or not set) /// </remarks>
I may be good idea to correct the environment variable name also on this page.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: c7ddfb2f-5dea-5e31-2a27-02a4dc16104c
- Version Independent ID: 12ca0b9a-2638-a4ce-c45f-d4579c83dafb
- Content: Enforce HTTPS in ASP.NET Core
- Content Source: aspnetcore/security/enforcing-ssl.md
- Product: aspnet-core
- GitHub Login: @Rick-Anderson
- Microsoft Alias: riande
@janpalas Are you using AddEnvironmentVariables explicitly (e.g., using the Generic Host or a WebHostBuilder), or are you relying upon CreateDefaultBuilder to add the env var config provider (e.g., using the WebHost)? If you are using AddEnvironmentVariables, are you specifying the prefix ASPNETCORE_?
@janpalas I'm adding your issue to the planned configuration work on #7102. Hopefully, we'll be able to solve the env var prefix problem everywhere once and for all.