Charity: Nginx, Bind, Grails, SSL etc
I was given an opportunity to help my wife setup a website for a charity she is involved in. It wasn’t anything particularly earth shaking, just a single page with a form for donating money via the web. Her charity wanted to run credit cards manually, since they have a credit card terminal. We would be collecting card info and thus we needed to have the traffic encrypted.
First things first I went and registered the domain packsoflove.com which is the domain my wife had chosen. Next I needed to setup DNS information for the new site, basically point the domain to my name servers so that our domain would resolve to the proper IP address. I used the registrars web based software to input the two name servers I manage. To finish the DNS setup I went and configured BIND on my servers so that they properly resolved packsoflove.com and www.packsoflove.com to my server’s IP. Now we had a place in the world wide web, but there wasn’t anything there!
At this point we needed an app. One that would be located at the domain we just setup. Since we where going to be processing form data it made sense to use a web application framework as opposed to a static site. The question was which framework to use? These past 10 or so years I’ve dived into a ton of them, writing apps of all size in numerous languages. For this task I choose Grails, partly because I’m going to be using it at my new job, but also because it’s very modular. You can install plugins for doing things like email or security and be done with it in minutes. Other choices that may have worked are Django, or Rails.
So I built the webapp, and it took a couple hours. I was having to prime myself a bit, I hadn’t done any Grails in over two years. I built a form for entering the card info that posts to a simple action which then emails off the data (securely of course) to my wife. I also built one more very very simple page that basically says thanks for donating and links back to the first page. So now I built the application and uploaded it to my server.
Grails runs on the Java language, and also uses most of the standards that Java has made famous (or is it infamous?) Anyhow you build a WAR file (short for webapplication resource file) which you install in an application container which serves up the app. In this case I used Jetty. It’s pretty easy to install via apt-get if you are using Ubuntu. Once installed you can put applications in the /usr/share/jetty/webapps folder. So I put the WAR file into the webapps/ folder, then rebooted Jetty. All good, except Jetty runs on localhost, which means it’s not accessible from the internet! What I had to do now is setup our proxy server, Nginx, so that it handles web requests for packsoflove.com and proxied them back to the Grails application running in Jetty, Pheeew!