Apache Virtual Hosts and Domain Redirection

You want to have the ability to redirect a subdomain but how best to go about it?  One way is to use Apache's Virtual Hosts (especially if you want to avoid using .htaccess), Redirect and the mod_alias module.

I wanted to redirect the entire www subdomain to my root domain so I did the following in my Virtual Host configuration file (located in apache2/sites-available):​

Breaking down the components of the Redirect statement looks like this:​

  • Redirect type: you can use permanent OR 301 as well as any of the other HTTP standard codes for redirect
  • Path to be redirected: I wanted the whole of the website redirected (hence I specified '/' ) but you could just as easily specify a subdirectory
  • URL to be redirect to: If the request had a path that did not exactly match the second argument, then all bits that followed would be appended to the destination URL (e.g. if the request was www.yourdomain.com/taco/bar.html, the redirect would look like yourdomain.com/taco/bar.html

You can still use the Redirect command in .htaccess if you so choose, it's just not my preference.​

Git, Fabric and Python - Tag You're It

There are many discussions that you can read about value of creating 'versions' or 'versioning' software.  More often then not, the versions (e.g. v 1.2.34) are used for marketing purposes or commercial product releases.  Does the internal engineering staff pay attention to such monikers on a daily basis?  Not really.  ​

​There are some instances, however, whereby knowing exactly which files on running on what server can come in handy.  

I wrote this Fabric task that can be called when doing a code push.  It tags the set of files with the name of the host machine the deploy is going to + a unique time stamp.  It also creates a 'tag' file which contains what branch of the code was used for this deployment.


Uncomplicated Firewall (UFW)

RackSpace's flavor of Ubuntu has installed the Uncomplicated Firewall and enables it by default (my experience).  Nice utility to manage the iptables for a local software based firewall.  ​

Enable UFW

To turn UFW on with the default set of rules:

sudo ufw enable

To check the status of UFW:

sudo ufw status verbose

Allow

sudo ufw allow <port>/<optional: protocol>

example: Allow incoming tcp and udp packet for MySQL

sudo ufw allow 3306  #open port for MySQL

example: To allow incoming tcp and udp packet on port 53

sudo ufw allow 53

example: To allow incoming tcp packets on port 53

sudo ufw allow 53/tcp

example: To allow incoming udp packets on port 53

sudo ufw allow 53/udp

Deny

sudo ufw deny <port>/<optional: protocol>

example: To deny tcp and udp packets on port 53

sudo ufw deny 53

example: To deny incoming tcp packets on port 53

sudo ufw deny 53/tcp

example: To deny incoming udp packets on port 53

sudo ufw deny 53/udp