Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 127.0.0.1:8888 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;
            server_name servername.com;
            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;
                                           break;
                          }
            }
}

upstream tiles {
    server 127.0.0.1:8888;
}

server {
    listen 8080;
    server_name tiles.servername.com;
    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 127.0.0.1:8888

fetches the page as expected

hitting tiles.servername.com:8080 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: http://pastie.org/2483294

share|improve this question

1 Answer 1

Got it figured out, start of with:

tilestream server starting with --host tiles.servername.com

Then edit /etc/hosts/ on the server:

127.0.0.1  tiles.servername.com

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

 
discard

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.