Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hosting Dashboard from child path (https://domain/my/child/path) does not appear to work correctly #4159

Open
jimcward opened this issue May 12, 2024 · 5 comments

Comments

@jimcward
Copy link

I am trying to host the aspire dashboard from k8s running on AKS using nginx as an ingress controller and running into some issues. I would essentially like to host the dashboard from:

https://mydomainhere/dev/aspire/dashboard

Using aspirate to generate some basic config I have managed to successfully deploy the dashboard out via helm and can access it from the above URL - it however immediately redirects to https://mydomainhere/structuredlogs

I believe it should be trying to redirect to https://mydomainhere/dev/aspire/dashboard/structuredlogs

I can put that directly into the browser and it then fails due to it trying to load js/css resources from https://mydomainhere/

I presume this might be related to it deploying out with a <base href="/">

I tried to see if setting ASPNETCORE_URLS as mentioned here https://learn.microsoft.com/en-us/dotnet/aspire/fundamentals/dashboard/configuration#common-configuration might help but that just leads to an error on startup:

Hosting failed to start
      System.InvalidOperationException: A path base can only be configured using IApplicationBuilder.UsePathBase()

I don't think I can "fix" this issue via ingress config as I have multiple other web apps running so can't just, for example, redirect any traffic to https://mydomainhere/ back out to https://mydomainhere/dev/aspire/dashboard

Is this a scenario that is not currently supported? Any advice would be greatly appreciated, thank you!

@PlPt-ads-tec
Copy link

it is not only the base href tag, all js sources, rely on hosting direclty on root path (/).
Even when i use IIS AAR (Reverse proxy) and replace base path and link strings, it will show a page, but js interactions are not working well.
Seems that this project is not prepared for hosting on subpaths. Maybe we get support in future as well.
For workaround i will use a separate port for it, directly mapping to aspire. Alternatively you can configure a second port in ingress and redirect it via https to aspire. i know it is annoying but i cant see an easy change.

@leslierichardson95 leslierichardson95 added this to the Backlog milestone Jul 2, 2024
@samsp-msft
Copy link
Member

This is an issue for the Blazor aspect of the Dashboard. If it's being hosted at a deeper url than expected, then the paths for loading other resources such as css or json will be wrong if they use absolute URLs.
IIRC there is not a standard way for the proxy to tell the application that there is a different base URL. What we could do would be to support a custom header in the proxy and use that as the <base href="/">. If the proxy is then configured to add that header, the dashboard can create absolute URLs that will work correctly.

@adityamandaleeka @benjaminpetit to confirm my memory for proxy related thoughts.

@aDisplayName
Copy link

@samsp-msft , For Blazor Server app, in App.razor, use the following to set the base href, all the static assets should be still accessible:

<head>
<!-- ... -->
 <base href="@_systemOptions.Value.DeploymentBaseHref" />
<!-- ... -->
</head>

@samsp-msft
Copy link
Member

We probably want a config property (an env var) for the base URI so that can be set in k8s etc for the standalone dashboard, as it will need to be the URI that the client accesses not the URI the dashboard is actually hosted at.

@davidfowl davidfowl added bug and removed bug labels Sep 16, 2024
ewassef added a commit to ewassef/aspire that referenced this issue Dec 18, 2024
This will allow the aspire app to handle running behind a reverse proxy such as a k8s ingress on a subpath
dotnet#4159
dotnet#4528
dotnet#5134
@ewassef
Copy link

ewassef commented Dec 18, 2024

I created a PR for this #6963

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants