Mohd Khalid — SimpleSignalR
Mohd Khalid

Mohd Khalid

Senior Software Engineer @ Straive • .NET Full-Stack • Exploring AI/ML

I build scalable web apps in ASP.NET Core (MVC/Web API), SQL Server & EF Core. Passionate about infrastructure-friendly tooling (cyberpanel-dotnet) and bringing AI/ML features into products.

Live Chat (SignalR)

Broadcasts to everyone on this page.

Health & Info

This site is powered by cyberpanel-dotnet — a tiny tool that makes it easy to run .NET Core apps behind CyberPanel/OpenLiteSpeed with proper reverse-proxy headers and a managed systemd service.

Status: Checking…
Scheme:
Host:
Client IP:
X-Forwarded-For:
X-Forwarded-Proto:

Quick endpoints: /healthz · /_debug

Show required Program.cs changes (reverse proxy)
// 1) Add these usings at top
using Microsoft.AspNetCore.HttpOverrides;
using System.Net;

// 2) Add this very early in the pipeline
var fwd = new ForwardedHeadersOptions
{
    ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto,
    ForwardLimit = 1 // trust only 1 proxy hop
};
fwd.KnownProxies.Add(IPAddress.Loopback); // OLS forwards from 127.0.0.1
app.UseForwardedHeaders(fwd);

// 3) Optional: add a debug endpoint
app.MapGet("/_debug", (HttpContext ctx) =>
    Results.Ok(new
    {
        scheme = ctx.Request.Scheme,
        host = ctx.Request.Host.Value,
        clientIp = ctx.Connection.RemoteIpAddress?.ToString(),
        xff = ctx.Request.Headers["X-Forwarded-For"].ToString(),
        xfp = ctx.Request.Headers["X-Forwarded-Proto"].ToString()
    })
);
    

Keep UseForwardedHeaders before HTTPS redirection, HSTS, auth, etc. After this, your app will correctly see https and the real client IP.