Search code examples
sslapache2subdomainmod-wsgigraphite

Apache subdomain for graphite using mod_wsgi and SSL


I am having trouble configuring my apache with a new subdomain.

Its a ubuntu server with apache2 and graphite, I have graphite working on port 80 (installed via apt-get)

Now the apache server currently serves a website (https://subdomain1.domain.com) and I would like to set up apache to serve the graphite app on https://subdomain2.domain.com (port 443). This is so subdomain1 can access the charts from graphite.

This is my apache2-graphite.conf

 <VirtualHost *:80>

    WSGIDaemonProcess _graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120 user=_graphite group=_graphite
    WSGIProcessGroup _graphite
    WSGIImportScript /usr/share/graphite-web/graphite.wsgi process-group=_graphite application-group=%{GLOBAL}
    WSGIScriptAlias / /usr/share/graphite-web/graphite.wsgi

    Alias /content/ /usr/share/graphite-web/static/
    <Location "/content/">
            SetHandler None
    </Location>

    ErrorLog ${APACHE_LOG_DIR}/graphite-web_error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/graphite-web_access.log combined

</VirtualHost>

and the /usr/share/graphite-web/graphite.wsgi :

import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'graphite.settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

from graphite.logger import log
log.info("graphite.wsgi - pid %d - reloading search index" % os.getpid())
import graphite.metrics.search

I have tried changing the port and setting a ServerName and ServerAlias, and enabling SSL, but I havent been able to get this working.

Sample (not working):

<IfModule mod_ssl.c>

<VirtualHost *:443>


        ServerName graphite.<my_domain_here>    

        WSGIDaemonProcess _graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120 user=_graphite group=_graphite
        WSGIProcessGroup _graphite
        WSGIImportScript /usr/share/graphite-web/graphite.wsgi process-group=_graphite application-group=%{GLOBAL}
        WSGIScriptAlias / /usr/share/graphite-web/graphite.wsgi

        Alias /content/ /usr/share/graphite-web/static/
        <Location "/content/">
                SetHandler None
        </Location>

        ErrorLog ${APACHE_LOG_DIR}/graphite-web_error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/graphite-web_access.log combined


        SSLEngine on

        SSLCertificateFile    /etc/apache2/ssl/public.crt
        SSLCertificateKeyFile /etc/apache2/ssl/private.key
        SSLCACertificateFile /etc/apache2/ssl/ca.crt


</VirtualHost>

Solution

  • I found what I was doing incorrectly:

    I added the subdomain to my /etc/hosts on my workstation and It worked!

    Registered the subdomain with our web host and all OK now

    Ill leave this here in case it helps someone else...