0

I've just set up a Sinatra app running on Unicorn and served through a socket by NGINX.

I'm trying to get NGINX to serve my static assets with this in my nginx config:

* EDIT * (added full server config)

upstream unicorn {
  server unix:/tmp/unicorn.app.sock fail_timeout=0;
}

server {
  listen 80 default;
  server_name localhost;
  root /home/ubuntu/app;

  location ^~ /public/ {
    root /home/ubuntu/app;
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }

  try_files $uri/index.html $uri @unicorn;

  location @unicorn {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://unicorn;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 10;
}

But my unicorn logs are still showing that it is serving the files

[03/Oct/2014 19:25:05] "GET /javascript/map.js HTTP/1.0" 304 - 0.0016
[03/Oct/2014 19:25:05] "GET /javascript/geopo.js HTTP/1.0" 304 - 0.0030
[03/Oct/2014 19:25:05] "GET /images/logo.png HTTP/1.0" 304 - 0.0022

etc.

What am I missing?

2
  • Why do you have a location matching /public/? Where is the rest of your server block? Oct 3, 2014 at 19:34
  • I'll post the whole thing. I'm matching public because that's where the assets are stored... Should this just be rules for root? I'm very new to this and just hacking my way through it trying to understand what's going on. I get the socket connection, but not how I can bypass unicorns serving of the files. Oct 3, 2014 at 19:40

0

You must log in to answer this question.

Browse other questions tagged .