INCLUDE_DATA

Entries from February 2009 ↓

Stopping SPAM and fake signups with mod_defensible and Apache on Ubuntu

Want to stop users from known blacklisted IP’s from accessing your site? Well, mod_definsible is the apache module for you. Here’s how to install it on Ubuntu:

sudo apt-get install libapache2-mod-defensible

then to enable the module do:

a2enmod defensible

Now create a file in /etc/apache2/mods-available/defensible.conf and put the following couple of lines in it:

DnsblUse On
DnsblServers xbl-bl.spamhaus.org. mydnbl.server.org.

Now restart apache and you’re all set. Now whenever a user that’s on spamhaus’s blocklist tries to access your site, they get a 403 Forbidden page.

Rails, passenger, ubuntu and EC2 - Part 1

I’ve been spending the better part of a year working on MoreDating, a dating site with a twist. It was and still is a joy to work on. I was asked to write my experience in deploying to EC2.

Let me start by saying that I am really impressed with EC2. It is super quick, and so far has been very stable. Let’s start with the technicalities.

Technical Specs:

  1. Ubuntu 8.04 Hardy
  2. Passenger 2.06
  3. Enterprise Ruby
  4. Large EC2 instance (8GB of RAM, 900 and change GB storage) @ $0.40/hour
  5. Image storage to S3
  6. MySQL database running off an EBS (Elastic Block Storage) drive

In this installment I will be talking about how I got EC2 up and running, and the preliminary configuration of the environment.

EC2 up and running with Ubuntu

I started out by getting an Amazon account, of course. You sign up by visiting: Amazon AWS. I then headed on to http://alestic.com/ to get the AMI that I need. Note that to use the 64-bit versions, you will need to setup a large EC2 instance. Now when I set it up, there wasn’t a pretty shiny interface for AWS, so I used elastic fox, the EC2 plugin for firefox (ElasticFox).

To spin up a new instance with all the necessary permissions, follow the Amazon EC2 Getting Started Guide . When it comes to the part about running an AMI, put in the ami path from the image you would like to use from alestic.

Once it’s up an running and you’re all connected, you can now start to configure it to your needs. Once we’re done with the configuration, we’ll go through taking an image of your instance so that you can spin other identical instances and to have a backup in case your instance goes haywire.

Configuring the goodies

  1. Install apache. Now, don’t go install any old apache, install the cool mpm-worker version. More information on that on the Apache Documentation Site . Install by running: sudo apt-get install apache2-mpm-worker
  2. Install ruby. Hold on, don’t go installing your vanilla ruby. Go to the good guys at phusion and download and install it. No vanilla ruby to install. Now we just need to make sure that it’s in the path server wide, so create a file in /etc/profile.d/ and call it ruby_path.sh and put this in it: export PATH=/opt/ruby/bin:$PATH. Now for this to work, make sure you have a symlink called /opt/ruby pointing to /opt/ruby/ruby-enterprise-lots-of-numbers-and-stuff-default-enterprise-installation-name. That way, whenever you install a new version of ruby enterprise edition, you just have to update the symlink.
  3. Install mysql (or postgres, or whatever). sudo apt-get install mysql-server (or whatever db server you’re going to use). Make sure you install the headers too.
  4. Little hack, I couldn’t figure out how to get it working properly. Whenever I try to install any gems using sudo, I have to provide the full path, so I made an alias for it in my .bash_profile: alias sgi=”sudo /opt/ruby/bin/gem install”. So now I just go: sgi some_gem
  5. Powered with this little hack, go ahead and run: sgi passenger. The installer is super friendly and will let you know exactly what is missing if you’re missing anything.

In my next post, I’ll be talking about capistrano setup, my deploy.rb script, and the costs of running EC2 full time + our use of S3 so far + our use of EBS.

Here’s a sample of the passenger and worker-specific of my apache2.conf and my bash_profile