title: PDF's not being served from from Rails app when proxied with Nginx
body: <p>I'm hoping somebody might be able to shed some light on this. We have a Rails 2 app that generates PDF's using the wicked_pdf library. We're running the app under unicorn proxied by nginx.</p>
  
  <p>The trouble is that whenever the app tries to serve a PDF it just times out and nginx reports a 404. I've checked the app via the unicorn port and it works fine so it's something happening between unicorn and nginx that's causing this to fail.</p>
  
  <p>Log files are not reporting anything useful. The application log just reports everything normally but doesn't output the <code>Sending data</code> line. The nginx log reports <code>*443 upstream prematurely closed connection while reading response header from upstream, client</code>.</p>
  
  <p>The unicorn error log reports that the connection is timing out and the worker is being killed, but the PDF generation does not take 30 seconds:</p>
  
  <pre><code>worker=2 PID:14099 timeout (31s &gt; 30s), killing
  reaped #&lt;Process::Status: pid=14099,signaled(SIGKILL=9)&gt; worker=2
  worker=2 ready
  </code></pre>
  
  <p>I feel like we've missed something in the nginx configuration for the site, but I'm not sure where to start looking.</p>
  
  <p>I've included the nginx config below:</p>
  
  <pre><code>server {
      listen *:80;
      server_name server_name.example.com;
      root /var/apps/application/current/public;
      try_files /system/maintenance.html $uri $uri/index.html @app;
      location @app {
          proxy_pass http://unix:/tmp/application.sock;
          proxy_set_header Host $http_host;
      }
      error_page 404 400 500 502 /error.html;
      location = /error.html {
          root /var/www;
      }
  }
  </code></pre>