Log in

No account? Create an account
Giza aka Douglas Muth's LiveJournal
Getting Nginx to work with Amazon EC2 dynamic IPs 
7th-Nov-2010 03:27 pm
Leopard White Mage
I've been playing with Amazon EC2 over the weekend, and trying to set up popular software packages on it. I was able to get Munin set up, but every time I tried to load the Munin webpages (e.g. http://ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com/munin/), I would get redirected to whatever the server_name directive was set to in Nginx. Usually it'd be something like "localhost", which was completely unhelpful.

I tried playing around with the server_name directive for awhile, and putting in the DNS name of the machine would work, but since I only used this instance sparingly, and starting it up caused it to be assigned a different IP each time, I would have to keep updating the config file. Not a viable solution.

I tried doing some fancy rewrites to the $server_name variable, but since Amazon's EC2 servers have their own internal IP in, my browser would just get redirected to an IP address that was not routable outside of Amazon's network.

I finally found the right directive:

server_name_in_redirect off;

This tells nginx to honor the Host: field in the initial HTTP request, instead of determining the name of the server on its own. This fixed the issue just fine.

Hopefully others will find this post and spend less time solving this problem than I did. :-)

(And yes, Ubuntu has official AMIs for EC2...)
7th-Nov-2010 09:41 pm (UTC)
Totally off-topic, but I love the fact that you named your site after the Norse word for "memory" :)
7th-Nov-2010 09:43 pm (UTC)

Which site? I run about half a dozen. :-P
7th-Nov-2010 11:25 pm (UTC)
Munin? It's an open source tool for monitoring servers. But good catch on the reference, I had never noticed!
8th-Nov-2010 02:43 am (UTC)
Ah. Technology and I are kind of work buddies, but we don't hang out much besides that :)
8th-Nov-2010 09:52 pm (UTC)
That's perfectly okay! Besides, apparently you're a donkey and donkeys are seriously awesome by default, so you get a pass regardless. :)
8th-Nov-2010 11:44 pm (UTC)
omg! this stuff just boggles mah mind!

9th-Nov-2010 12:34 am (UTC)

9th-Nov-2010 02:25 am (UTC)
All this webhosting biz is just boggling mah mind!
Can your correct me at MFF? please!


This page was loaded Dec 10th 2018, 3:26 pm GMT.