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 10.0.0.0/8, 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...)