HTTPS redirection never turns on
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Đọc src/Exceptionless.Web/Program.cs quanh các dòng 271–275 và kiểm tra cách chuyển hướng HTTPS được cấu hình so với UseForwardedHeaders() và RunAsync(). Issue đề xuất xóa bước kiểm tra địa chỉ đã liên kết bên ngoài Development; hãy xem xét các tùy chọn hiện có và hành vi của middleware trước khi chọn thay đổi đó. Công việc được xem là hoàn tất khi các yêu cầu HTTP được chuyển hướng sang HTTPS nếu đã cấu hình endpoint HTTPS, còn các yêu cầu đã được nhận diện là HTTPS thì không bị chuyển hướng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Program.cs decides whether to add UseHttpsRedirection() by checking the server's bound addresses while the pipeline is being built. Kestrel only fills in those addresses when the app starts, so the list is always empty at that point and the middleware is never added.
Where
src/Exceptionless.Web/Program.cs L271-L275:
var serverAddressesFeature = app.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>();
bool ssl = options.AppMode != AppMode.Development && serverAddressesFeature is not null && serverAddressesFeature.Addresses.Any(a => a.StartsWith("https://"));
if (ssl)
app.UseHttpsRedirection();
This runs before app.RunAsync().
What happens
A self-hosted instance listening on both HTTP and HTTPS (for example ASPNETCORE_URLS=http://+:8080;https://+:8443 with a certificate) serves plain HTTP on the HTTP port with no redirect. Setting an HTTPS port (EX_HTTPS_PORT) has no effect.
A minimal ASP.NET Core 10 app shows the timing:
var app = WebApplication.CreateBuilder(args).Build();
var f = app.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>()!;
Console.WriteLine($"Before start: [{string.Join(",", f.Addresses)}]");
await app.StartAsync();
Console.WriteLine($"After start: [{string.Join(",", f.Addresses)}]");
With ASPNETCORE_URLS=http://127.0.0.1:59123 this prints Before start: [] and After start: [http://127.0.0.1:59123].
Expected
When the server has an HTTPS endpoint outside Development, HTTP requests are redirected to HTTPS.
Suggested fix
Add app.UseHttpsRedirection() outside Development without the address check. The middleware resolves the HTTPS port lazily on the first request (from HttpsRedirectionOptions.HttpsPort, the HTTPS_PORT setting, or the bound addresses) and does nothing, with a single warning, when there is no HTTPS endpoint. It runs after UseForwardedHeaders(), so requests that arrive over HTTPS at a trusted proxy are not redirected. If redirection should stay opt-in, gate it on a config value instead (for example the existing EnableSsl option) rather than on bound addresses.
- Ngôn ngữ chính
- C#
- Star
- 2.5k
- Fork
- 508
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 40
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của exceptionless/Exceptionless
-
bug documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
exceptionless/Exceptionless#2707 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
exceptionless/Exceptionless#2706 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
exceptionless/Exceptionless#2705 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
exceptionless/Exceptionless#2704 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
exceptionless/Exceptionless#2703 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của exceptionless/Exceptionless
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 89/100
getsentry/sentry-dotnet#5833 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: core priority: low type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
RicoSuter/Namotion.Interceptor#863 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
bitfoundation/bitplatform#14428 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area-cli
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày