Skip to content

Instantly share code, notes, and snippets.

@eneldoserrata
Created January 23, 2018 04:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eneldoserrata/5a397f201ea90cc664544a717c310117 to your computer and use it in GitHub Desktop.
Save eneldoserrata/5a397f201ea90cc664544a717c310117 to your computer and use it in GitHub Desktop.
Superset serve on nginx with prefix
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, ]
@stonecharioteer
Copy link

Did this work for you?

@ramdesh
Copy link

ramdesh commented Oct 8, 2019

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