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

static content is not loaded when using nginx-ingress with custom base path #132

Closed
troian opened this issue Jun 4, 2019 · 6 comments · Fixed by #134
Closed

static content is not loaded when using nginx-ingress with custom base path #132

troian opened this issue Jun 4, 2019 · 6 comments · Fixed by #134

Comments

@troian
Copy link

troian commented Jun 4, 2019

We would like to get polaris dashboard accessible from subpath of our domain (e.g. https://example.com/polaris)

Issue is static content is not loaded as deployment expects them without polaris path.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example.com-polaris
  namespace: polaris
  annotations:
    kubernetes.io/ingress.provider: "nginx"
    kubernetes.io/ingress.class: "nginx-ks"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
    nginx.ingress.kubernetes.io/secure-backends: "false"
    nginx.ingress.kubernetes.io/rewrite-target: "/$1"
    nginx.ingress.kubernetes.io/configuration-snippet: |
      rewrite ^(/polaris)$ $1/ permanent;
spec:
  tls:
    - hosts:
        - example.com
      secretName: star-example-com
  rules:
    - host: cluster.notifai.io
      http:
        paths:
          - path: /polaris/?(.*)
            backend:
              serviceName: polaris-dashboard
              servicePort: 8080
@rbren
Copy link
Member

rbren commented Jun 5, 2019

Thanks for the report! This was fixed in 0.1.5.

To serve the dashboard on a base path like /polaris, you'll need to set --dashboard-base-path="/polaris/"

#136 will add this as an option to the helm chart. You can also alter the file at ./deploy/dashboard.yaml.

Hope that helps! Let me know if you have any trouble.

@troian
Copy link
Author

troian commented Jul 29, 2019

Does not seem to work unfortunately.
When trying to access dashboard within internal link without custom path it works fine

adding --dashboard-base-path="/polaris/" breaks that so neither example.com/polaris/ nor internal link works

@rbren
Copy link
Member

rbren commented Sep 30, 2019

@troian - sorry, I missed your follow-up message. I've reopened this issue for now.

When I set up an Ingress similar to yours using nginx-ingress (config below), combined with the --dashboard-base-path flag, example.com/polaris works as expected (though accessing the service via kubectl port-forward doesn't work).

We have an open PR that would mount the router on the path provided in --dashboard-base-path, which I think would obviate the need for the rewrite rule, and allow both the service and the external URL to work.

Here's my Ingress, which works as expected:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: example.com-polaris
  namespace: polaris
  annotations:
    kubernetes.io/ingress.class: "nginx-ingress"
    certmanager.k8s.io/cluster-issuer: "letsencrypt-prod"
    certmanager.k8s.io/acme-challenge-type: dns01
    certmanager.k8s.io/acme-dns01-provider: route53
    kubernetes.io/ingress.ssl-redirect: "true"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"

    nginx.ingress.kubernetes.io/rewrite-target: "/$1"
    nginx.ingress.kubernetes.io/configuration-snippet: |
      rewrite ^(/polaris)$ $1/ permanent;
spec:
  tls:
    - hosts:
        - polaris.example.com
      secretName: polaris-cert
  rules:
    - host: polaris.example.com
      http:
        paths:
          - path: /polaris/?(.*)
            backend:
              serviceName: polaris-dashboard
              servicePort: 8080

@rbren
Copy link
Member

rbren commented Jan 9, 2020

I believe this is fixed now - feel free to reopen if not

@rbren rbren closed this as completed Jan 9, 2020
@osaffer
Copy link

osaffer commented Oct 19, 2020

Hi,

Can you show where you set this parameter --dashboard-base-path ? I install by applying the yaml file.

Thank you

@hmdmph
Copy link

hmdmph commented Jan 12, 2022

With helm just remember the ending / is required end of the path and ingress works just fine.

--set dashboard.basePath=/polaris/

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

Successfully merging a pull request may close this issue.

4 participants