iandouglas.com | senior web architect

I learned a little something about nginx, a small footprint web server that is ideal for serving up mobile sites, or sites where you don’t want the heavy usage of Apache. Today, I needed to solve a problem where we redirected iPhone/iPod users to a different URL. Since nginx doesn’t use the old-style mod_rewrite rules, I had to learn how to enable redirection in the server.

Since nginx was already compiled with redirection support, I simply had to locate the correct configuration file and add a few lines of code, and away it went.

First, I checked out /etc/nginx/ and opened the site configuration file within the /sites-enabled/ path. For this example, let’s say the site was m.iandouglas.com:

# vi /etc/conf/nginx/sites-enabled/m.iandouglas.com

In here, I’d look for the ’server’ block and add my redirection rules:

server {
	listen      80;
	server_name m.iandouglas.com;
        root /var/www/m.iandouglas.com/public;

	# redirect iPhone/iPod users to the new iphone site
        if ($http_user_agent ~* '(iPhone|iPod)') {
                rewrite ^/$ http://m.iandouglas.com/iphone/index.html;
        }
.
.
.

Then a simple nginx restart:

# /etc/init.d/nginx restart

… and we were all set.

,

Jan/10

20

dream come true

I think I was 8 years old when my dad came home with a Commodore 64 and various games. Hacking up those games in C64 Basic is what got me interested in programming, and now 20-something years later I landed a job at Armor Games as a Sr Web Developer. Not doing game programming, but I *am* in the industry where I’m happiest, and the web development work so far has been a nice change from the heavy lifting I’ve been doing in Perl for so long. For obvious reasons I won’t blog about specifics going on here at the office, but I may share insights into some of the things I’m learning.

,

CNET posted a HOWTO video on how to enable a much broader Control Panel setup by creating a folder with a specific filename.

In a nutshell, create a folder in the root level of any drive, and call it “GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}” (without the quotes).

quick and simple: edit /etc/hosts
(or on Windows machines: C:\WINDOWS\system32\drivers\etc\hosts)
and add the following:

0.0.0.0 www.facebook.com facebook.com apps.facebook.com
0.0.0.0 www.myspace.com myspace.com
0.0.0.0 www.digg.com digg.com

etc. Add as many sites as you want. When you want to stop being productive at work, simply comment out those lines (like during a lunch break). Just be sure to uncomment the lines when you need to be productive again…

,

Dec/09

31

happy new year

all the best for 2010, everyone!

No tags

Older posts >>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes

 

February 2010
S M T W T F S
« Jan    
 123456
78910111213
14151617181920
21222324252627
28  

Archives

Theme Design by devolux.org