Configurable basepath/url for nginx reverse proxing on diff location other than /?
Is there any way to configure caravel to accept requests under /my-whatever-path/.....? I would like to reverse proxy caravel using nginx but not on / location block.
Google suggests this http://flask.pocoo.org/snippets/35/ . Feel free to open a pull request if it works for you.
It did work, but then I ran into countless absolute links that I haven't found a way to put them behind a prefix. Any ideas?
@michailsal does url_for work correctly? If so it is just matter or using it thoroughly.
url_for does work for the most part, but still there are many hardcoded absolute links e.g.
./templates/caravel/sql.html: <img id="loading" width="25" style="display: none;" src="/static/assets/images/loading.gif">
./templates/caravel/welcome.html: <img class="loading" src="/static/assets/images/loading.gif"/>
./templates/caravel/explore.html: <img src="{{ url_for("static", filename="assets/images/loading.gif") }}" class="loading" alt="loading">
./templates/caravel/standalone.html: <img src="{{ url_for("static", filename="img/loading.gif") }}" class="loading" alt="loading">
Shall I just fix them by adding url_for (which I have already done locally) and open a pull request?
@michailsal yes, please!
Is there any news regarding these changes / pull request ?
The same issue applies on wsgi serving with Apache for example: in apache config: WSGIScriptAlias /myapp /var/www/dashboard/flaskacct.wsgi
but immediately I get a 404 with http://myhost/caravel/welcome without preserving the baseurl like http://myhost/myapp/caravel/welcome.
I haven't had time to work on this, I do know though that even if somehow you manage to preserve the baseurl and not being redirected, there are still many absolute links pointing to "/" instead of using "url_for"
Somewhat related to this, I did a brute force thing with apache to get it (almost) working:
ProxyPass /caraveldata/ http://caravel:8088/
ProxyPassReverse /caraveldata/ http://caravel:8088/
<Location /caraveldata/>
Header edit Location ^https?://([^/]+)/(.*)$ https://$1/caraveldata/$2
RequestHeader unset Accept-Encoding
ProxyHTMLEnable On
ProxyHTMLExtended On
ProxyHTMLURLMap / /caraveldata/
ProxyHTMLURLMap /caraveldata/ /caraveldata/
</Location>
This almost works, but then I run into issues with JavaScript, because it does things like for example in welcome.js:
// Builds a dataTable from a flask appbuilder api endpoint
let url = '/' + modelView.toLowerCase() + '/api/read';
I don't see a good way of fixing that, without touching caravel source code in quite a few places. I am considering to introduce another sub-domain to be able to proxy my backend caravel app without the need to use paths. I was just trying to avoid it because another sub-domain means I need to separately configure it with our single-sing-on.
Is anyone working this? I just tried to put Gunicorn (serving Superset) behind an nginx proxy. Some links work, but others didn't.
This is relevant part from my nginx config file:
location /prefix/ { proxy_pass http://172.26.0.4:8088/prefix/; # <- gunicorn server proxy_set_header SCRIPT_NAME /prefix; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
In Superset, I tried with and without ENABLE_PROXY_FIX (not sure what this setting does?). So without digging deeper, it looks like the issue is still hardcoded urls?
I have made a proof of concept that works behind a proxy.
The python code changes were fairly straightforward by switching hard coded urls for Flasks' url_for.
The JS though... I just did the hacky thing by templating serverRoot and staticRoot global js variables that are then used to build the urls. It works fine, but is probably not the best.
I would love to contribute this back, but need some guidance on how to approach the JS side of things.
@joharohl if we have the code i'd say to just open a PR for the python code and we can discuss about the js. We can update the PR later or just open a new one.
related https://github.com/apache/incubator-superset/issues/3690
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.
so what is the purpose for WEBDRIVER_BASEURL in config?
I found it very frustrating to setup a base url for superset. If you want to save some time, I condensed a couple of comments into a working example here: https://github.com/komoot/superset-reverse-nginx-example
@christophlingg So how to implement your working example in latest apache superset on master by running it under gunicorn? Just need to have the nginx in docker-compose.yml and nginx.conf right?
@syazwan0913 I dont know if there are already docker images for the current master. you can try put latest in the docker version here https://github.com/komoot/superset-reverse-nginx-example/blob/master/docker-compose.yml#L13
see also https://github.com/amancevice/docker-superset#versions
@christophlingg Right now I am using the code from here https://github.com/apache/incubator-superset
When I used your nginx.conf, the site can be load and the URL prefix is based on my configuration. But the problem is static files like html, js, images is not showing. Is it I missing something?
@christophlingg the static files showed already but another problem came up. When I run docker-compose up --build -d, there is problem with it run RUN rm /etc/nginx/conf.d/default.conf.
@christophlingg problem solved already. thanks