Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

HTTPS redirection never turns on

Đang mở Phù hợp với người mới
#2,694 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
backend

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ả

bug

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

Mở trong Codespaces

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.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của exceptionless/Exceptionless

Tất cả issue của exceptionless/Exceptionless

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.