URL prefix for Superset
Asked Answered
R

2

0

I am an issue where i need to prefix superset app ie the URLs generated by superset need to be prefixed with '/dev'. I tried to fix it using Blurprints but superset doesn't seem to take into consideration blueprints with url_prefix.

The main reason the need for me is I am trying to deploy superset on AWS Lambda on a serverless environment and since AWS API Gateway adds a stage name like '/dev' all the links are broken. I am able to get to the login page but most of them doesn't work because it seems it's trying to access resources at "/" but API Gateway puts all of them at "/dev".

Any other way or do we need to modify all the static URLs?

Can you help me to see if someone can get Blueprints working on superset with url_prefix option?

Rectory answered 12/6, 2018 at 1:30 Comment(0)
K
2

As I answered in How to get Apache Superset to run on a specified path, this issue covers what you're talking about:

https://github.com/apache/incubator-superset/issues/985

which led to this closed PR:

https://github.com/apache/incubator-superset/pull/1866

You can try to reopen the PR and finish it, or you can try configuring nginx like this guy suggests.

Kvass answered 21/6, 2018 at 13:8 Comment(1)
I was able to get it working on AWS Lambda at /dev endpoint. Need to do changes to front-end as well as python code to include /dev when the links are being created and redirects are being used in Python Code. For front-end react resources, as of now I have hard-coded /dev at all the places where they redirect to an end-point. Need to do this in an elegant way so that it's configurableRectory
S
1

I tried reverse proxy with sub_filter. I haven't checked that all the rules have been added, but most of them seem to work.

Take a look at https://github.com/mskimm/prefixed-superset

My approach is

  1. reverse proxy /{subpath}/ to /
  2. add {subpath} to all urls using sub_filter

This is nginx configuration

upstream superset-nginx {
    server superset:8088;
}

server {
  listen 80;

  location ^~ /${SUPERSET_CONTEXT_PATH}/ {
    rewrite ^/${SUPERSET_CONTEXT_PATH}/(.*)$ /$1?$args break;
    proxy_pass http://superset-nginx;

    sub_filter_types *;
    sub_filter_once off;
    sub_filter '/api/v1/' '/${SUPERSET_CONTEXT_PATH}/api/v1/';
    sub_filter 'api/v1/' '${SUPERSET_CONTEXT_PATH}/api/v1/';
    sub_filter '/dashboard/' '/${SUPERSET_CONTEXT_PATH}/dashboard/';
    sub_filter '/chart/' '/${SUPERSET_CONTEXT_PATH}/chart/';
    sub_filter '/superset/' '/${SUPERSET_CONTEXT_PATH}/superset/';
    sub_filter '/tabstateview/' '/${SUPERSET_CONTEXT_PATH}/tabstateview/';
    sub_filter '/savedqueryview/' '/${SUPERSET_CONTEXT_PATH}/savedqueryview/';
    sub_filter '/databaseview/' '/${SUPERSET_CONTEXT_PATH}/databaseview/';
    sub_filter '/tablemodelview/' '/${SUPERSET_CONTEXT_PATH}/tablemodelview/';
    sub_filter '/static/assets/' '/${SUPERSET_CONTEXT_PATH}/static/assets/';
    sub_filter '/static/appbuilder/' '/${SUPERSET_CONTEXT_PATH}/static/appbuilder/';
    sub_filter '/users/' '/${SUPERSET_CONTEXT_PATH}/users/';
    sub_filter '/roles/' '/${SUPERSET_CONTEXT_PATH}/roles/';
    sub_filter '/rowlevelsecurityfiltersmodelview/' '/${SUPERSET_CONTEXT_PATH}/rowlevelsecurityfiltersmodelview/';
    sub_filter '/logmodelview/' '/${SUPERSET_CONTEXT_PATH}/logmodelview/';
    sub_filter '/annotationlayermodelview/' '/${SUPERSET_CONTEXT_PATH}/annotationlayermodelview/';
    sub_filter '/csstemplatemodelview/' '/${SUPERSET_CONTEXT_PATH}/csstemplatemodelview/';
    sub_filter '/logout/' '/${SUPERSET_CONTEXT_PATH}/logout/';
    sub_filter '/explore/' '/${SUPERSET_CONTEXT_PATH}/explore/';
    sub_filter '/tableschemaview/' '/${SUPERSET_CONTEXT_PATH}/tableschemaview/';
    sub_filter 'href="/back"' 'href="/${SUPERSET_CONTEXT_PATH}/back"'; # no tailing slash

    proxy_redirect     'http://$host/' '/${SUPERSET_CONTEXT_PATH}/';
    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;          
  }
}
Sibelle answered 28/9, 2022 at 14:12 Comment(1)
didnt work for me...Unsling

© 2022 - 2024 — McMap. All rights reserved.