Umbraco Forms IP Address tracking

If you’re using something like Sucuri as a website firewall along side with umbraco forms, how can we track IP addresses outside of the firewall for users who make form submissions? If the IP address tracking is turned on, the firewall IP address is provided in the back-end. Any thoughts?

Here’s the related docs for forms:

and Sucuri:

The XFF header should be used by default. But you you look at the MS docs you can set up a custom header if you need to - which might be the case for Sucuri:

Which could look something like this, though it’s hard to tell from the Sucuri docs:

builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
    options.ForwardedForHeaderName = "HTTP-X-SUCURI-CLIENTIP";
});
1 Like

Thanks! I didn’t even see this reply for some reason. I’m still not too clear on how to do this. Are you able to provide a step-by-step?

First step is really to confirm if HTTP_X_SUCURI_CLIENTIP is the right header - hopefully Sucuri support can help with that - though I guess you could just try the code snippet and see.

If your project has a Startup.cs, just drop the snippet at the top of the ConfigureServices() method like so:

public void ConfigureServices(IServiceCollection services)
{
    services.Configure<ForwardedHeadersOptions>(options =>
    {
        options.ForwardedForHeaderName = "HTTP-X-SUCURI-CLIENTIP";
    });

    // services.AddUmbraco() etc...

If you only have a Program.cs, then pop this snippet just after CreateBuilder() like so:

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
    options.ForwardedForHeaderName = "HTTP-X-SUCURI-CLIENTIP";
});

// builder.CreateUmbracoBuilder() etc...

That might be enough to get it working for you.