Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a unicorn app server running a rails app and a tilestream server serving up tiles one listens on local unix socket, and the other on here is my conifg:

upstream unicorn_server {
   server unix:/var/www/fulcrumapp/tmp/sockets/unicorn.sock;

  client_header_buffer_size 128k;
  large_client_header_buffers 4 128k;

  server {
            listen 80;
            keepalive_timeout 30;
            root   /var/www/servername/public/;
                        location / {
                          proxy_set_header  X-Real-IP  $remote_addr;
                          proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
                          proxy_set_header Host $http_host;
                          proxy_redirect off;

                          client_max_body_size 300m;

                          if (!-f $request_filename) {
                                           proxy_pass http://unicorn_server;

upstream tiles {

server {
    listen 8080;
    access_log /var/www/servername/log/tilestream-tiles.access.log;
    error_log /var/www/servername/log/tilestream-tiles.error.log debug;

    location / {
        proxy_set_header Host $http_host;
        proxy_pass http://tiles;

the first server works fine... the "tiles" server kicks back "bad request" 400 errors

on the local server running: curl

fetches the page as expected

hitting fails.

this is an amazon EC2 instance where the public IP is not the local server IP but I don't think the amazon NAT layer is getting in the way.

server OS is ubuntu 11.04

debug nginx log here:

share|improve this question

Got it figured out, start of with:

tilestream server starting with --host

Then edit /etc/hosts/ on the server:

Then proxy config as above.

The "Bad Request" was coming from the tilestream server.
The --host parameter specifies the ONLY hosts it will accept connections from.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.