apache/pulsar

Dashboard assets referenced from absolute path fail to load when running behind a proxy

Closed this issue · 2 comments

Describe the bug
After deploying the dashboard to kubernetes, and configuring the ingress from the chart correctly, the dashboard is referencing assets from an absolute server path instead of the path behind the proxy.

I am running an nginx ingress controller in front of the dashboard, proxying to the dashboard based on the path /pulsar.

To Reproduce
Steps to reproduce the behavior:

  1. Configure the dashboard ingress values like:
  ingress:
    enabled: true
    annotations:
      kubernetes.io/ingress.class: nginx
      nginx.ingress.kubernetes.io/rewrite-target: "/$2"
    tls: {}
    hostname: "example.com" 
    path: "/pulsar(/|$)(.*)"
    port: 80
  1. Install the chart via helm, and an ingress controller separately.
  2. Visit the root of dashboard application via the ingress controller (http://example.com/pulsar/)
  3. View assets attempting to load from absolute path, instead of prefixed with /pulsar

Expected behavior
Assets will load properly through the ingress controller

Screenshots
Screen Shot 2019-11-11 at 3 50 14 PM

Desktop (please complete the following information):

  • OS: macOS (irrelevant)

Additional context
This cluster is running in AKS, and the ingress is being deployed via the nginx-ingress chart

I'm not very familiar with django and python, but after some searching I think this could be configured via a uwsgi parameter, but the chart has no such configurations. I also could forward all traffic for the dashboard-related assets (e.g. /static/, /admin) directly to the pulsar dashboard, but would strongly prefer to be able to run the complete server on the /pulsar path.

f-ld commented

Got this issue as well (before giving up with dashboard using a LOT of memory and not being of any use because of many bugs. But I did not try latest versions).

I did fix it with a workaround in dashboard deployment yaml:

                # Thus is a terrible patch to get uwsgi/django serve the dashboard under /pulsar path
                command: ["sh", "-c"]
                args:
                  - >
                    sed -i "s#STATIC_URL = '/static/'#STATIC_URL = '/pulsar/static/'#" /pulsar/django/dashboard/settings.py &&
                    sed -i "s#\[uwsgi\]#[uwsgi]\nroute-run = addvar:SCRIPT_NAME=/pulsar#" /pulsar/conf/uwsgi.ini   &&
                    /pulsar/start.sh

i.e. add this command and args entries to perform a couple sed commands before running the default /pulsar/start.sh script. This was (at least on 2.3.x, to be confirmed with latest versions) patching the code of the dashboard to get it working with same configuration.