Run Hue under a custom url location

56 views
Skip to first unread message

Danci Emanuel

unread,
Jun 1, 2016, 2:22:21 PM6/1/16
to Hue-Users
Hi everyone,

I am trying to get Hue to run on a custom location, something like: <hostname>/hue/. 
Is there an elegant solution to achieve this? 

I have tried running Hue behind nginx and doing proxy_pass to the cherrypy instance that is 
running on a different port. The problem is that once I am in Hue, if I click on different links they
will be handled by cherrypy, thus being sent to <hostname>/<request_uri> instead of <hostname>/hue/<request_uri>. 

My nginx config looks like this:
 
server {
    server_name cluster-node1;
    charset utf-8;
    listen 8001;

    location /hue/ {
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Host $server_name;

        proxy_pass http://cluster-node1:8888/;
    }

    location /static/ {
        # Or if on a parcel install:
        alias /opt/cloudera/parcels/CDH/lib/hue/build/static/;

        expires 30d;
        add_header Cache-Control public;
    }
}

Thanks,
Emanuel

Romain Rigaux

unread,
Jun 1, 2016, 11:57:48 PM6/1/16
to Danci Emanuel, Hue-Users

--
You received this message because you are subscribed to the Google Groups "Hue-Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hue-user+u...@cloudera.org.

Enrico Berti

unread,
Jun 2, 2016, 5:16:29 AM6/2/16
to Romain Rigaux, Danci Emanuel, Hue-Users
Another additional thing: the static files import (so JS, CSS and images) won't work if Hue is in a subfolder, because it will try to load from the root of the url

Danci Emanuel

unread,
Jun 6, 2016, 7:14:06 AM6/6/16
to Hue-Users, rom...@cloudera.com, danci....@gmail.com

@Enrico, can the default behaviour be changed so that the files get server properly?

Danci Emanuel

unread,
Jun 6, 2016, 11:31:13 AM6/6/16
to Hue-Users, rom...@cloudera.com

Never mind... I managed to bypass the url patterns construction (static / dynamic) but now I saw that some of the urls are hard-coded in the 
common_header.mako and everything breaks. 

Enrico Berti

unread,
Jun 6, 2016, 11:41:55 AM6/6/16
to Danci Emanuel, Hue-Users, Romain Rigaux
Hi!
They are not hardcoded, they are all with a reference to ${ static('') }, which is a middleware that helps with both development and deployment of Hue with the static files served by another web server (ie: http://gethue.com/using-nginx-to-speed-up-hue-3-8-0/)


Danci Emanuel

unread,
Jun 6, 2016, 11:50:23 AM6/6/16
to Hue-Users, danci....@gmail.com, rom...@cloudera.com
How about this one: 
<a href="/${apps['beeswax'].display_name}"> 
(from ./desktop/templates/common_header.makp +439)

Does it get processed by some custom middleware as well?

Thanks! 

Enrico Berti

unread,
Jun 6, 2016, 12:06:58 PM6/6/16
to Danci Emanuel, Hue-Users, Romain Rigaux
Oh but that's not a static file, that's a link and it resolves to something that is served by Hue....

What if instead of putting it in a subfolder, you put it in a 3rd level domain or run in on a different port?

Enrico Berti

unread,
Jun 6, 2016, 12:15:31 PM6/6/16
to Danci Emanuel, Hue-Users, Romain Rigaux
What about something like Apache's RewriteEngine? That could solve it?

Danci Emanuel

unread,
Jun 6, 2016, 12:54:23 PM6/6/16
to Hue-Users, danci....@gmail.com
Indeed, I got past the static files issue by updating how the urlpatterns are built. Pardon me for 
the mistake. 

In regards to how the app is served, unfortunately it has to be served from the /hue/ location.

I will dig deeper into nginx rewrite rules. One of the problems that I possibly see is that normally if 
a Django app is served on from a non-root location I can use the FIX_SCRIPT_NAME setting or send the 
SCRIPT_NAME via an HTTP header to serve it from that location. I am not sure I can do that 
with CherryPy though. I will have to dig deeper to see if I can fix this somehow. 

Thanks again! 

Enrico Berti

unread,
Jun 6, 2016, 3:25:32 PM6/6/16
to Danci Emanuel, Hue-Users
Oh that'd be cool if you find a solution! And if you do, you could write it up on our blog maybe? :)

Thanks!
e.

Danci Emanuel

unread,
Jun 7, 2016, 1:07:52 AM6/7/16
to Hue-Users, danci....@gmail.com

I will let you know if I come up with such a solution. Thanks for the help so far. 

Emanuel
Reply all
Reply to author
Forward
0 new messages