Search code examples
amazon-web-servicesubuntu-12.04apache-bloodhound

Running apache bloodhound on apache2 web server


I am trying to run to apache bloodhound tracker on apache2 web server. I am using 0.7 version of the blood hound. I followed the website https://issues.apache.org/bloodhound/wiki/BloodhoundInstall

Blood hound is running on port 8000. But the problem is I am not able to run the blood hound on port 80, so that if I hit bloodhound.mydomain.com, I should get bloodhound. I have mentioned my apache2 webserver setting file as specified in the website /etc/apache2/sites-available/bloodhound

<VirtualHost *:8080>
   WSGIDaemonProcess bh_tracker user=ubuntu python-path=/home/ubuntu/bloodhound-0.7/installer/bloodhound/lib/python2.7/site-packages
   WSGIScriptAlias /bloodhound /home/ubuntu/bloodhound-0.7/installer/bloodhound/site/cgi-bin/trac.wsgi
   <Directory /home/ubuntu/bloodhound-0.7/installer/bloodhound/site/cgi-bin>
     WSGIProcessGroup bh_tracker
     WSGIApplicationGroup %{GLOBAL}
     Order deny,allow
     Allow from all
   </Directory>
   <LocationMatch "/bloodhound/[^/]+/login">
     AuthType Digest
     AuthName "ubuntu"
     AuthDigestDomain /bloodhound
     AuthUserFile /home/ubuntu/bloodhound-0.7/installer/bloodhound/environments/main/bloodhound.htdigest
     Require valid-user
   </LocationMatch>
 </VirtualHost>

After adding the above file, its not running on either of the ports 8000 and also 8080 also.

How do I make it run. Kindly help me. By the way I am using ubuntu ec2 instance.


Solution

  • By golly I think I've figured it out! I've been stuck right about where you are on my own Bloodhound port configuration for days.

    n3storm is correct: the whole magic of setting up mod_wsgi is that you no longer need to manually start bloodhound with that

     tracd port=8080 /ridiculously/long/path/to/bloodhound/installer/bloodhound/environments/main
    

    command. Instead, mod_wsgi runs all that python for you the moment your web browser requests http://[host]:8080/bloodhound, meaning your Bloodhound server is ready to serve the moment it's turned on.

    The pain is how many interlocking config files are involved, and how many tiny things can break down the whole process. I don't really know python, I just barely understand Apache, and I'm 70% confident I've accidentally opened some gaping security that I don't understand, but here's my understanding of the mod_wsgi + Apache + Bloodhound domino chain. Paths are for my Apache 2.4 installation on Ubuntu 14.04.1 LTS:

    1. You load http://[host]:8080/bloodhound

    For this to work, I needed to edit /etc/apache2/ports.conf so that Apache is actually listening on port 8080. So add the line

    Listen 8080
    

    to /etc/apache2/ports.conf

    Now visiting http://[host]:8080/bloodhound should at least show you something from Apache. For me, it was a HTTP Error 403: Forbidden page, and next up is my home remedy for the Error 403 blues!

    2. Apache triggers bloodhound.conf

    FULL PATH: /etc/apache2/sites-available/bloodhound.conf

    Technically, Apache is looking in /etc/apache2/sites-enabled/ for a matching VirtualHost rule but you set this up by creating/editing .conf files in /sites-availabe/ and then activating them with the Apache command

    a2ensite [sitename].conf
    

    So. Apparently, Apache 2.4 changed its access control syntax for .conf files. So, to stop the Error 403ing, I changed

    Order deny,allow
    Allow from all
    

    in /etc/apache2/sites-available/bloodhound.conf to

    Require all granted
    

    And then once again you should restart Apache with

    sudo apachectl graceful
    

    or

    sudo /etc/init.d/apache2 graceful
    

    or maybe

    sudo service apache2 restart
    

    I'm not sure, they all seem to work equally but I suppose the graceful ones are nice because they don't shut down your server or something important like that.

    3. bloodhound.conf triggers trac.wsgi

    FULL PATH: /ridiculously/long/path/to/bloodhound/installer/bloodhound/site/cgi-bin/trac.wsgi

    After figuring out that ton of other things, I realized that, in the end, the default script that Bloodhound generates worked fine for me:

    import os
    
    def application(environ, start_request):
        if not 'trac.env_parent_dir' in environ:
            environ.setdefault('trac.env_path', '/usr/local/bloodhound/installer/bloodhound/environments/main')
        if 'PYTHON_EGG_CACHE' in environ:
            os.environ['PYTHON_EGG_CACHE'] = environ['PYTHON_EGG_CACHE']
        elif 'trac.env_path' in environ:
            os.environ['PYTHON_EGG_CACHE'] = \
                os.path.join(environ['trac.env_path'], '.egg-cache')
        elif 'trac.env_parent_dir' in environ:
            os.environ['PYTHON_EGG_CACHE'] = \
                os.path.join(environ['trac.env_parent_dir'], '.egg-cache')
        from trac.web.main import dispatch_request
        return dispatch_request(environ, start_request)
    

    4. trac.wsgi serves up the HTML files for Bloodhound

    Isn't the internet just magical?