Teaching Horizon to Share

Horizon is The OpenStack Dashboard. It is a DJango (Python) Web app. During a default installation, Horizon has resources at one level under the main Hostname in the URL scheme. For example, authentication is under http://hostname/auth.

Devstack performs single system deployments. Packstack has an “all-in-one” option that does the same thing. If these deployment tools are going to deploy other services via HTTPD, Horizon needs to be taught how to share the URL space. Fortunately, this is not hard to do.

A naive approach might just say “why not reserve suburls for known applications, like Keystone or Glance?” There are two reasons that this is not a decent approach. First is that you do not know what other applications OpenStack might need to deploy in the future. The other reason is that DJango has a well known mechanism that allows an administrator to deploy additional web UI functionality alongside existing. Thus, an end deployer could very well have a custom webUI for Keystone running at http://hostname/dashboard/keystone. We can’t block that. DJango provides the means for a very neat solution.

In horizon, you can get away with setting the WEBROOT variable. I made my changes in openstack_dashboard/settings.py as I am intending on submitting this as a patch:

WEBROOT='/dashboard'
LOGIN_URL =  WEBROOT+'/auth/login/'
LOGOUT_URL =  WEBROOT+'/auth/logout/'
 # LOGIN_REDIRECT_URL can be used as an alternative for
 # HORIZON_CONFIG.user_home, if user_home is not set.
 # Do not set it to '/home/', as this will cause circular redirect loop
LOGIN_REDIRECT_URL =  WEBROOT 

However, you can achieve the same effect for your deployments by setting the values in openstack_dashboard/local/local_settings.py for devstack or the comparable file in a Puppet or Chef based install.

However, DJango is no longer managing the root url for your application. If you want to make the transition seamless, you need to provide for a redirect from http://hostname to http://hostname/dashboard. This is an Apache HTTPD configuration issue, and not something you can do inside of DJango.

On a Fedora based install, you will find a file /etc/httpd/conf.d/welcome.conf. In a default deployment, it points to the Fedora “Welcome” page.

Alias /.noindex.html /usr/share/httpd/noindex/index.html

There are many ways to use this. Here’s how I did it. It might not be the neatest. Feel free to comment if you have something better.

Create a file /var/www/html/index.html with the following body:

<META HTTP-EQUIV="Refresh" Content="0; URL=/dashboard/">

Then, modify welcome.conf to have:

Alias /.noindex.html /var/www/html/index.html

Now users that land on http://hostname are redirected to http://hostname/dashboard.

3 thoughts on “Teaching Horizon to Share

  1. The webroot variable handling and that stuff is a small patch, that I introduced for Fedora and RHOS packaging. It’s good to know, someone found it useful. I should submit it upstream sooner or later.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>