#!/bin/bash

# Install apache
/usr/bin/apt-get -y install apache2
cat > /var/www/html/index.html <<EOD
<html><head><title>${HOSTNAME}</title></head><body><h1>${HOSTNAME}</h1>
<p>This is the default web page for ${HOSTNAME}.</p>
</body></html>
EOD

sed -i 's/80/8000/g' /etc/apache2/ports.conf 
sed -i 's/80/8000/g' /etc/apache2/sites-enabled/000-default.conf

# Log the X-Forwarded-For
perl -pi -e  's/^LogFormat "\%h (.* combined)$/LogFormat "%h %{X-Forwarded-For}i $1/' /etc/apache2/apache2.conf
/usr/sbin/service apache2 restart
