question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

resource pathing behind nginix ingress

See original GitHub issue

We’re attempting to run a dotvvm site in Kubernetes behind a Nginx ingress.

while everything works locally, even if run from a docker container, when running behind the ingress we’re seeing issues where the site wont load.

its specifically failing trying to find a ‘dotvvm–internal’ script at the (example) url https://myCoolURLhere.com/dotvvmResource/jUwMRn0laxpYA4BX1REy/dotvvm--internal behind the ingress the path should be https://myCoolURLhere.com/assessments/dotvvmResource/jUwMRn0laxpYA4BX1REy/dotvvm--internal

We were originally also having problems getting bootstrap and our css to load, changing from the following

config.Resources.Register("bootstrap-css", new StylesheetResource() { Location = new UrlResourceLocation("~/Content/bootstrap.min.css") }); to config.Resources.Register("bootstrap-css", new StylesheetResource() { Location = new UrlResourceLocation("./Content/bootstrap.min.css") });

fixes the pathing to bootstrap, and the css files when behind the ingress.

Is there a property or configuration setting I can adjust so that it looks for the dotvvm–internal script with the appropriate ingress path included ?

Thanks.

Issue Analytics

  • State:closed
  • Created 4 months ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tomashercegcommented, Jun 1, 2023

I was able to get it running with a combination of ingress (without rewriting) and UsePathBase:

ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: kubernetesvirtualdirectorytest-ingress
  labels:
    service: kubernetesvirtualdirectorytest
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
  - host: "kubernetesvirtualdirectorytest.local"
    http:
      paths:
      - path: /sub-app
        pathType: Prefix
        backend:
          service:
            name: kubernetesvirtualdirectorytest
            port: 
              number: 80

Startup.cs

...
app.UsePathBase("/sub-app");
app.UseRouting();
...

Are you using rewrite rule on the ingress to remove the /assessments segment? I think this would be the problem - the app needs to know it is running in a virtual directory so it would generate the URLs correctly.

0reactions
exyicommented, Jul 26, 2023

I’m closing this, I assume it worked. Please reopen or open a new issue if the problem persists

Read more comments on GitHub >

github_iconTop Results From Across the Web

Regular expressions in paths - Ingress-Nginx Controller
The ingress controller supports case insensitive regular expressions in the spec.rules.http.paths.path field. This can be enabled by setting the ...
Read more >
Basic Configuration | NGINX Ingress Controller
The Ingress resource only allows you to use basic NGINX features – host and path-based routing and TLS termination. Advanced features like rewriting...
Read more >
kubernetes - nginx ingress sub path redirection
I have an ingress controller and ingress resource running with all /devops mapped to devopsservice in the backend. When I try to hit...
Read more >
NGINX Ingress Resources with Configuration Examples
NGINX Ingress resources are an alternative available for both the NGINX Open Source and NGINX Plus-based versions of NGINX Ingress Controller. They provide...
Read more >
How to configure path based routing with ingress on ...
In my setup, ingress controller was using app=ingress-nginx label and is present in ingress-nginx namepsace. This will expose nginx-controller ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found