title: nginx serving Django static media | 502 bad gateway
body: <p>I'm trying to serve Django static media through nginx, Here's my nginx.conf</p>
  
  <pre><code>server {
      listen       7777;
      listen       localhost:7777;
      server_name  example.com;
  
      location / {
          proxy_pass http://localhost:7777;
          proxy_redirect off;
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          client_max_body_size 10m;
          client_body_buffer_size 128k;
          proxy_connect_timeout 90;
          proxy_send_timeout 90;
          proxy_read_timeout 90;
          proxy_buffer_size 4k;
          proxy_buffers 4 32k;
          proxy_busy_buffers_size 64k;
          proxy_temp_file_write_size 64k; 
      }
  
      location /test-app-media/ {
          root /sites/mysite/staticmedia/;
          expires max;
        }
  }
  </code></pre>
  
  <p>but give a <code>502 bad gateway</code> error, the path to <code>/sites/mysite/staticmedia/</code> is in the nginx root/ is that the problem.. </p>
  
  <hr>
  
  <p>Django running on Apache 2.2 + mod_wsgi</p>
  
  <p>nginx 0.7.65</p>
  
  <p>Thanks..</p>