Hangfire Dashboard URL mismatch

Created on 13 Feb 2018  路  10Comments  路  Source: HangfireIO/Hangfire

I mapped the Hangfire Dashboard to the route /hangfire.

app.UseHangfireDashboard("/hangfire")

The Dashboard is reachable by the URL https://app-dev.example.com/exampleapp/api/hangfire/ after deployment, but the Dashboard URLs point to https://app-dev.example.com/hangfire/. Because of this, the Dashboard does not work. Is anywhere a possibility to change the BaseUrl of the Dashboard?

hangfire_dashboard

Most helpful comment

Following workaround works, because our load balancer fills the request header X-Forwarded-Prefix. Instead of this header you can also use a fix value or a setting for different environments.

app.Use((context, next) =>
{
  if (context.Request.Path.StartsWithSegments("/hangfire"))
  {
    context.Request.PathBase = new PathString(context.Request.Headers["X-Forwarded-Prefix"]);
  }
  return next();
});

app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
  Authorization = new[] {new DashboardAuthorizationFilter()},
  AppPath = _appSettings.CurrentValue.WebUiUri
})
.UseHangfireServer(backgroundJobServerOptions);

All 10 comments

Webforms, MVC, Self Hosted? Can you let us see your OWIN Startup class?

I use MVC inside a ASP.Net core webservice which is hosted in IIS. I use the method extension https://github.com/HangfireIO/Hangfire/blob/master/src/Hangfire.AspNetCore/HangfireApplicationBuilderExtensions.cs#L31 to register the Dashboard.

And what happens if you use /exampleapp/api/hangfire/ instead of just hangfire ?

What is your applications relative root path?

The app is hosted at

https://app11.example.com/hangfire/
https://app12.example.com/hangfire/

and we call the app with the url (load balancer)

https://loadbalancer.example.com/app1/hangfire/

The dashboard includes e.g. the CSS stylesheet by /hangfire/css1617. But the stylesheet is not available at https://loadbalancer.example.com/hangfire/css161. Instead the stylesheet should be imported by /app1/hangfire/css1617. So we need the possibility to configure the basepath /app1.

hangfire_dashboard2

Hi,
I have the same issue...
Do you have any solution/workaround ?

thanks

I don't really have a solution. Our workaround is to call the dashboard directly without the load balancer.

@flomuson @wolfmarco must be similar to #1049

The Hangfire Dashboard tries to load the CSS and JS files by https://loadbalancer.example.com/hangfire/css161 instead of https://loadbalancer.example.com/app1/hangfire/css161. The URL https://loadbalancer.example.com/hangfire/ does not exist. I don't understand how a rewrite/redirect should work in this case.

Following workaround works, because our load balancer fills the request header X-Forwarded-Prefix. Instead of this header you can also use a fix value or a setting for different environments.

app.Use((context, next) =>
{
  if (context.Request.Path.StartsWithSegments("/hangfire"))
  {
    context.Request.PathBase = new PathString(context.Request.Headers["X-Forwarded-Prefix"]);
  }
  return next();
});

app.UseHangfireDashboard("/hangfire", new DashboardOptions
{
  Authorization = new[] {new DashboardAuthorizationFilter()},
  AppPath = _appSettings.CurrentValue.WebUiUri
})
.UseHangfireServer(backgroundJobServerOptions);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

abdelrady picture abdelrady  路  4Comments

dealproc picture dealproc  路  3Comments

shorbachuk picture shorbachuk  路  4Comments

cbmek picture cbmek  路  3Comments

odinserj picture odinserj  路  4Comments