I put a proxy on Hue

I put a proxy on Hue

A Web proxy lets you centralize all the access to a certain URL and prettify the address (e.g. ec2-54-247-321-151.compute-1.amazonaws.com --> demo.gethue.com).

Screenshot from 2014-06-11 17:46:27

Have you ever wondered how we got Hue working under a proxy on demo.gethue.com? (if you missed the Cluster setup video, here it is!)

Here’s a sample configuration we use on our servers. We know the Apache web server pretty well so we went for it. We even configured the server to display a custom error page in case the Hue server is down/not working.

What you need to do is to install and enable the mod_proxy module (e.g. a2enmod proxy_http) and then configure the main virtual host (on Ubuntu it’s /etc/apache2/sites-available/000-default.conf) to just proxy and reverse proxy any request to your Hue instance (and any HTTP 503 error to another path):

<VirtualHost *:80>
  ProxyPreserveHost On

  ProxyPass /error/ http://localhost:81/error/
  ProxyPassReverse /error http://localhost:81/error/
  ProxyPass / http://_HUE_INSTANCE_IP_:8888/ connectiontimeout=15 timeout=30
  ProxyPassReverse / http://_HUE_INSTANCE_IP_:8888/
  SetEnv proxy-nokeepalive 1
  ErrorDocument 503 /error/

  ServerName demo.gethue.com
</VirtualHost>

Change demo.gethue.com with your qualified server name available on your internal or external DNS.

and then add an additional virtual host (running on a different port, 81 for instance, on /etc/apache2/sites-available/001-error.conf) to serve the error path you specified in the default vhost:

<VirtualHost *:81>
  DocumentRoot /var/www/
</VirtualHost>

in /var/www you need to have a folder error with an index.html inside (need inspiration? look here!) that is going to be displayed when Hue is not reachable.

The last thing we need to do is to tell Apache we are listening to the port 81 as well, so edit /etc/apache2/ports.conf and just add

  Listen 81

After everything, let’s restart Apache with sudo service apache2 restart and… et voila! You are good to go!

Screenshot from 2014-06-11 17:44:11

5 Comments

  1. Jenn 8 months ago

    Did you have issues with the Metastore manager link no longer working after enabling the reverse proxy?

  2. Bob 6 months ago

    I have an issue setting up a proxy for my hue server. My apache is on a different server and I’m running into the following issue. My virtual host configuration is shown below. both hue and the apache are SSL enabled.

    ServerName hueservername
    RewriteEngine On
    ProxyPreserveHost On
    SSLProxyEngine On

    ProxyPass https://hueserver:8008/ retry=0 ttl=60 disablereuse=On
    ProxyPassReverse https://hueserver:8008/

    When i keep the PreserveHost option on, the url changes from proxyserver/hue/login to proxyserver/login and it fails

    if i turn off the PreserveHost option, the url is fine but i get 403 errors trying to log in.

    Is there a way around this? The proxy works fine if i keep the base as “/” but i need it to be “/hue” on the apache server

    • Author
      Hue Team 6 months ago

      Hi, we don’t support Hue residing in a /folder yet, so it needs to be at the root of the domain. You can try though maybe with mod_rewrite?

Leave a reply

Your email address will not be published. Required fields are marked *

*