AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

Wrong HTTPS environment variable in documentation

Open gh5692 opened this issue 1 year ago • 8 comments

Description

It looks like the wrong environment variable is specified in the UseHttpsRedirection and Port configuration sections of the documentation. It says to set the ASPNETCORE_HTTPS_PORTS variable, but https://github.com/aspnet/Announcements/issues/301 says to use ASPNETCORE_HTTPS_PORT (no ending 'S'). I tried both in an Azure Web App, and only the ASPNETCORE_HTTPS_PORT enforced a redirect for me.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/security/enforcing-ssl?view=aspnetcore-8.0&tabs=visual-studio%2Clinux-ubuntu

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/security/enforcing-ssl.md

Document ID

12ca0b9a-2638-a4ce-c45f-d4579c83dafb

Article author

@tdykstra


Associated WorkItem - 297872

gh5692 avatar Aug 16 '24 15:08 gh5692

@amcasey what do you think -- everything I have found indicates the one with S on the end is correct

tdykstra avatar Aug 16 '24 16:08 tdykstra

There's an S: https://github.com/dotnet/aspnetcore/blob/bc0ed99129fb20b2f12da93fb10d60c1812a6101/src/Hosting/Abstractions/src/WebHostDefaults.cs#L64

amcasey avatar Aug 16 '24 16:08 amcasey

Wait, I've never seen that one in the middleware before. The constant I linked was added in 8.0.

amcasey avatar Aug 16 '24 16:08 amcasey

Well, that's concerning: we appear to also have a no-S env var: https://github.com/dotnet/aspnetcore/blob/42af9fe6ddd7c3f9cde04ac003bf97509881873b/src/Middleware/HttpsPolicy/src/HttpsRedirectionMiddleware.cs#L127

amcasey avatar Aug 16 '24 17:08 amcasey

@Tratcher were you aware of HTTPS_PORT when you added HTTPS_PORTS? Do you have any expectations around how they should interact?

amcasey avatar Aug 16 '24 17:08 amcasey

Educated guess: HTTPS_PORTS means "listen on the following ports for HTTPS connections" and HTTPS_PORT means "if you get a non-HTTPS connection, redirect to this port".

amcasey avatar Aug 16 '24 17:08 amcasey

Educated guess: HTTPS_PORTS means "listen on the following ports for HTTPS connections" and HTTPS_PORT means "if you get a non-HTTPS connection, redirect to this port".

This is correct, but I can understand the confusion between them. That's what docs are for 😆.

Tratcher avatar Aug 17 '24 04:08 Tratcher

#31538 made a number of changes from PORT to PORTS that we should revisit with this in mind to see if they need to be reverted.

tdykstra avatar Aug 21 '24 18:08 tdykstra

@gh5692 Thanks for reporting this! It's corrected in https://github.com/dotnet/AspNetCore.Docs/pull/33489

tdykstra avatar Aug 30 '24 20:08 tdykstra