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 server set on a VPS serving up a production Rails app via Nginx + Unicorn. Presently this works fine with the following conf files:

However the added subdomain of staging.appname.tld ends up yielding the following error in /var/log/nginx/error.log:

2012/08/20 16:57:39 [error] 24673#0: *174 upstream timed out (110: Connection timed out) while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: staging.appname.com, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.appname_staging.sock:/", host: "staging.appname.com"
2012/08/20 16:58:17 [error] 24673#0: *178 upstream timed out (110: Connection timed out) while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: staging.appname.com, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.appname_staging.sock:/", host: "staging.appname.com"
2012/08/20 16:59:29 [error] 24673#0: *182 upstream timed out (110: Connection timed out) while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: staging.appname.com, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.appname_staging.sock:/", host: "staging.appname.com"

The configurations proffering this error are:

Additionally, the socks do exist! If we look in /tmp/ we see: unicorn.appname.sock and unicorn.appname_staging.sock

And here is the nginx -V output.

It would seem as though something is off in the config, however I'm just not seeing it. Could someone please advise as to where this error is coming from and how to properly set up subdomains such as a staging environment in this context?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I don't see anything that's wrong in your config, although some minor stuff to improve but nothing that should break it. Could you please activate debug logging and post the log here.

And please have a look at the following revised configuration (with activated debug logging).

upstream unicorn_appname_staging {
  server unix:/tmp/unicron.appname_staging.sock max_fails=0;
}

server {
  listen 80;
  index index.html;
  root /home/deployer/apps/appname/staging/current/public;
  server_name staging.appname.com;

  client_max_body_size 4G;
  keepalive_timeout 10;

  access_log /var/log/nginx/staging.appname.com.access.log;
  error_log /var/log/nginx/staging.appname.com.error.log debug;
  error_page 500 502 503 504 /500.html;

  location / {
    location ^~ /assets/ {
      gzip_static on;
      expires max;
      add_header Cache-Control public;
    }

    try_files $uri @unicorn_appname_staging;
  }

  location @unicorn_appname_staging {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_redirect off;
    proxy_pass http://unicorn_appname_staging;
  }
}
share|improve this answer
    
When adding debug to the end of root /home/deployer/apps/appname/staging/current/public; nginx replied with the following error on restart: Starting nginx: nginx: [emerg] invalid number of arguments in "root" directive in ... Running version 1.2.2-0ubuntu0ppa2~precise. –  ylluminate Aug 21 '12 at 0:04
    
SORRY! Fully my mistake, I put it on the wrong spot. I corrected it, now it's correct. Again SORRY! –  Fleshgrinder Aug 21 '12 at 0:11
    
additionally there are no additional results when I append debug to the error_log line. –  ylluminate Aug 21 '12 at 0:13
    
Okay, so yes, I already had tried that addition earlier and then again here, but there is no additional output in the error log. It makes me think that there must be some going wrong with unicorn, however it works fine in production and the sock is present... –  ylluminate Aug 21 '12 at 0:14
1  
Okay, great that you were able to pin it down. :) –  Fleshgrinder Aug 21 '12 at 10:37
show 7 more comments

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.