emesday / prefixed-superset

Adds context path (url prefix, sub path) of Apache Superset by NGINX reverse proxy and sub_filter.
MIT License
16 stars 6 forks source link

Prefixed superset using helm chart and ingress-nginx #7

Open davidconalrobinson opened 8 months ago

davidconalrobinson commented 8 months ago

Hello - I'm wondering if you have any guidance on how I can adapt this solution to create a prefixed superset deployment using the superset helm chart and an ingress-nginx ingress controller?

I'm thinking that it should be possible to add your nginx config to the ingress resource here using an ingress-nginx annotation - but I'm at a bit of a loss as to how to actually make this work. If you have any ideas I'd be super grateful 🙏

davidconalrobinson commented 8 months ago

Actually after some trial and error I got it (mostly) working 😅

ingress:
  enabled: true
  ingressClassName: nginx
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-staging
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/configuration-snippet: |
      rewrite ^/superset/(.*)$ /$1?$args break;
      sub_filter_types *;
      sub_filter_once off;
      sub_filter '/api/v1/' '/superset/api/v1/';
      sub_filter 'api/v1/' 'superset/api/v1/';
      sub_filter '/superset/' '/superset/superset/';
      sub_filter '/static/assets/' '/superset/static/assets/';
      sub_filter '/static/appbuilder/' '/superset/static/appbuilder/';
      sub_filter '/dashboard/' '/superset/dashboard/';
      sub_filter '/dashboardasync/' '/superset/dashboardasync/';
      sub_filter '/chart/' '/superset/chart/';
      sub_filter '/users/' '/superset/users/';
      sub_filter '/lang/' '/superset/lang/';
      sub_filter '/roles/' '/superset/roles/';
      sub_filter '/logout/' '/superset/logout/';
      sub_filter '/login' '/superset/login'; # no tailing slash
      sub_filter '/explore/' '/superset/explore/';
      sub_filter '/alert/' '/superset/alert/';
      sub_filter '/tabstateview/' '/superset/tabstateview/';
      sub_filter '/savedqueryview/' '/superset/savedqueryview/';
      sub_filter '/savedqueryviewapi/' '/superset/savedqueryviewapi/';
      sub_filter '/databaseview/' '/superset/databaseview/';
      sub_filter '/tablemodelview/' '/superset/tablemodelview/';
      sub_filter '/rowlevelsecurityfiltersmodelview/' '/superset/rowlevelsecurityfiltersmodelview/';
      sub_filter '/logmodelview/' '/superset/logmodelview/';
      sub_filter '/annotationlayermodelview/' '/superset/annotationlayermodelview/';
      sub_filter '/csstemplatemodelview/' '/superset/csstemplatemodelview/';
      sub_filter '/csstemplateasyncmodelview/' '/superset/csstemplateasyncmodelview/';
      sub_filter '/tableschemaview/' '/superset/tableschemaview/';
      sub_filter '/csvtodatabaseview/' '/superset/csvtodatabaseview/';
      sub_filter '/columnartodatabaseview/' '/superset/columnartodatabaseview/';
      sub_filter '/exceltodatabaseview/' '/superset/exceltodatabaseview/';
      sub_filter '/annotationmodelview/' '/superset/annotationmodelview/';
      sub_filter 'href="/back"' 'href="/superset/back"'; # no tailing slash
      proxy_set_header Accept-Encoding "";
      proxy_set_header Host $host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  path: /superset
  pathType: Prefix
  hosts:
    - my.domain.com
  tls:
    - secretName: letsencrypt-staging
      hosts:
        - my.domain.com

I think there are some sub filters that I need to add (for example, if I click the + DASHBOARD button it redirects me to http://my.domain.com,my.domain.com/dashboard/new/.

lreneral commented 2 months ago

@davidconalrobinson hi, does it work for you? if yes what did you change? Did you change some values/variable in superset_config.py? regards