title: NGINX in front of TOMCAT to serve static files
body: <p>I'm working on a project with <code>grails 2.2.2</code> on a local machine <code>Mac OSX Lion 10.7.5</code> I have installed <code>NGINX</code> with <code>brew</code> and modified the <code>nginx.conf</code> as following :</p>
  
  <pre><code>worker_processes  1;
  error_log  logs/error.log  info;
  
  events {
      worker_connections  1024;
  }
  
  
  http {
      include       mime.types;
      default_type  application/octet-stream;
  
      log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                        '$status $body_bytes_sent "$http_referer" '
                        '"$http_user_agent" "$http_x_forwarded_for"';
  
      access_log  logs/access.log  main;
  
      sendfile        on;
      keepalive_timeout  65;
  
      server {
          listen       8081;
          server_name  localhost;
  
      root /;
  
      access_log /Users/lorenzo/grails/projects/logs/myproject_access.log;
  
          location / {
              proxy_set_header X-Forwarded-Host $host;
              proxy_set_header X-Forwarded-Server $host;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Real-IP $remote_addr;
              proxy_pass http://localhost:8081;
          }
  
      #images folders
      location /posters {
          root /Users/lorenzo/grails/projects/posters/;   
      }
  
      #images folders
      location /avatars {
          root /Users/lorenzo/grails/projects/avatars/;
      }
  
      #images folders
      location /waveforms {
          root /Users/lorenzo/grails/projects/waveforms/;     
      }
  
      error_page   500 502 503 504  /50x.html;
      location = /50x.html {
          root   html;
      }
  }
  </code></pre>
  
  <p>When I access <code>http://localhost:8081</code> my site is running but I want to be sure the <code>images</code> are served by <code>nginx</code> and not by <code>tomcat</code> so I look at <code>myproject_access.log</code> but nothing is happening.</p>
  
  <p><code>ngnix</code> is writing into the log <strong>ONLY</strong> when <code>tomcat</code> is <strong>NOT</strong> running.</p>
  
  <p>Is there a way to "monitor" the static files served by <code>nginx</code> ? </p>
  
  <p>Thank you</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>Executing curl -I http://localhost:8081
  </code></pre>
  
  <p>when tomcat is running the output is:</p>
  
  <pre><code>HTTP/1.1 200 OK
  Server: Apache-Coyote/1.1    //TOMCAT
  ...
  </code></pre>
  
  <p>when tomcat is NOT running the output is:</p>
  
  <pre><code>HTTP/1.1 500 Internal Server Error
  Server: nginx/1.4.1   //NGINX
  Date: Tue, 08 Apr 2014 09:30:00 GMT
  Content-Type: text/html
  Content-Length: 192
  Connection: keep-alive 
  </code></pre>