Created
January 23, 2018 04:24
-
-
Save eneldoserrata/5a397f201ea90cc664544a717c310117 to your computer and use it in GitHub Desktop.
Superset serve on nginx with prefix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hi. | |
Here is the content of my nginx config file : | |
location /analytics { | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Script-Name /analytics; | |
proxy_pass http://YOUR_SERVER_NAME:8088; | |
#YOUR_SERVER_NAME is localhost if both nginx and superset run on same server | |
} | |
location ~ ^/(static|superset|sqllab|savedqueryview|druid|tablemodelview|databaseasync|dashboardmodelview|slicemodelview) { | |
try_files $uri /analytics/$uri /analytics/$uri?$query_string @rules; | |
} | |
location @rules { | |
rewrite ^(.*)$ /analytics$1 permanent; | |
} | |
Also, don't forget to put the middleware in the superset_config.py file : | |
class ReverseProxied(object): | |
def __init__(self, app): | |
self.app = app | |
def __call__(self, environ, start_response): | |
script_name = environ.get('HTTP_X_SCRIPT_NAME', '') | |
if script_name: | |
environ['SCRIPT_NAME'] = script_name | |
path_info = environ['PATH_INFO'] | |
if path_info.startswith(script_name): | |
environ['PATH_INFO'] = path_info[len(script_name):] | |
scheme = environ.get('HTTP_X_SCHEME', '') | |
if scheme: | |
environ['wsgi.url_scheme'] = scheme | |
return self.app(environ, start_response) | |
ADDITIONAL_MIDDLEWARE = [ReverseProxied, ] |
Did this work for you?
Yes, it works. Make sure your prefix itself is not /superset
though, if you do that it'll go in to a redirect loop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did this work for you?