superset icon indicating copy to clipboard operation
superset copied to clipboard

[SIP-102] Allow Superset to run in a sub path URL

Open maudrid opened this issue 1 year ago • 4 comments

[SIP-102] Proposal to allow Superset to run in a sub path URL

Motivation

At our company we host our application for customers with Superset as part of the service. We have a URL scheme as follows: https://<customer-name>.<service-domain>.com For each customer we now have 2 domains because we also need https://superset.<customer-name>.<service-domain>.com as well as the afore mentioned one, since Superset only runs successfully on the root. We also cannot use a wildcard domain certificate like *.service-domain.com because wildcard certificates do not work on sub-sub domains. So now we have to create additional domain certificates for each customer.

Proposed Change

It would be great if we can run superset behind a reverse proxy on a sub path. For example: https://<customer-name>.<service-domain>.com/superset Some configuration options to enable this behaviour would be required: Grafana, for example, has these options:

serve_from_sub_path = true
root_url = https://<customer-name>.<service-domain>.com/superset

maudrid avatar Jul 27 '23 13:07 maudrid

https://github.com/apache/superset/pull/1866 https://github.com/apache/superset/issues/22842 https://github.com/apache/superset/issues/22850 https://github.com/apache/superset/issues/985

glego avatar Sep 22 '23 09:09 glego

Have you taken stock of the scope of this fix by prototyping a solution or enumerating the parts where things break? Since Flask supports this by default, we need to sort out what redirects need to be addressed here for things to work - it might be straightforward, or lead to more difficulties. Can you provide a bit more detail here to flesh this out? This might just be a bugfix and not require a SIP (which you're welcome to work on). But if it's complex, we need to explain the fix and raise it for a [DISCUSS] thread.

rusackas avatar Nov 01 '23 18:11 rusackas

I have tried to apply the Flask settings that is supposed to set the root URL for the application. I'm not sure if I am doing it correctly, but it did not have any effect. Here is what I added to my superset_config.py file:

APPLICATION_ROOT = "/test"

Also tried:

from flask import Flask
def FLASK_APP_MUTATOR(app: Flask) -> None:
    app.config['APPLICATION_ROOT'] = "/test"

Also tried

from flask import Flask, current_app
app = Flask(__name__)
with app.app_context():
    current_app.config['APPLICATION_ROOT'] = "/test"

If I try to visit the /test path, I get 404 not found. Could anyone tell me if I'm doing this wrong?

maudrid avatar Nov 02 '23 11:11 maudrid

Hi @maudrid - just checking in to see if you're still working on this. If you want to continue with this as a SIP, I think you'll need to follow through with some additional steps: • Filling out the remainder of the SIP template • Sending off a [DISCUSS] thread on the mailing list • Beginning the implementation or seeking others (potentially here or on Slack) to help with implementation

Otherwise, this might be more of a feature request, which we should move over to a GitHub Discussion.

For good measure, pinging @nytai and @dpgaspar in case they have some insight on the best way to approach this.

rusackas avatar Apr 04 '24 01:04 rusackas

@rusackas I don't currently have resources that can work on this. We are not a python house. Maybe you are correct that this is more of a feature request at the moment. From the documentation of Flask, it seems that setting the configuration should allow this to work, but as you can see from my attempts, it did not work. Could this be a bug then?

maudrid avatar Apr 07 '24 17:04 maudrid

Thanks for the follow up @maudrid - if this is a feature request, I'll go ahead and close this SIP as discarded, though anyone who ever finds the thread and decides to act on it can reboot the process, and we'll happily reopen the issue for further discussion/voting/implementation. For now, I'd say it's not a bug, since Superset works as advertised/intended. You're welcome to open an "Ideas" thread on Github Discussions to find interested parties who want to help.

rusackas avatar Apr 08 '24 17:04 rusackas