Unable to access Hangfire Dashboard and Service Fabric app with reverse proxy


#1

Hi, I’m using Hangfire in Service Fabric (SF) project and I have a problem accessing to the dashboard in the non local cluster when trying to access to the dashboard within one of the services (dotnet core app) deployed using SF reverse proxy.

For Example:
https://path.to.app.com/appName/serviceName/hangfire

I’m able to get to the dashboard but the references to the links and styles in the dashboard page is like /hangfire/jobs and I need to be able to set it up like /appName/serviceName/hangfire/jobs.

I set it up the pathMatch in the useHangfireDashboar to /appName/ServiceName/hangfire and it didn’t work. Any ideas.
Thanks.


#2

Hi,

Have a look at the documentation here: http://drunkcoding.net/working-with-service-fabric-reverse-proxy

For the WebHostBuilder configuration add:

UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.UseReverseProxyIntegration)

and in Startup.cs add:

const string ServiceNameUrl = "YOURAPP/YOURSERVICE";
 
app.Use((context, next) =>
{
    if (context.Request.Headers.TryGetValue("X-Forwarded-Host", out var _))
        context.Request.PathBase = $"/{ServiceNameUrl}";
 
    return next();
});

Cheers.