Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I currently have nginx proxying for Thin, but set up to serve static files for the app that Thin is serving instead of proxying the request.

What I'd like to know is how I can check that the rules are set up correctly. Since Thin doesn't log requests, I would need to set up nginx logs in such a way that it shows which requests were served as files and which were passed to Thin. Is this even possible? If so, how?

share|improve this question
up vote 2 down vote accepted

Depending on your configuration, it may be easy to achieve. Here is my solution...

server {
  root /path/to/files;
  # index index.php index.html;

  # logging of all requests in access.log
  access_log /some/path/such/as/var/log/nginx/access.log;

  location / {
    try_files $uri $uri @thin;

  location @thin {
    # pass the requests to thin
    # proxy_pass http://thin;

    # proxy specific logging in proxy-access.log
    access_log /some/path/such/as/var/log/nginx/proxy-access.log;

Hope this helps!

share|improve this answer
i tried to use upstream_addr for host it didnt work – Muhammad Umer Mar 26 '15 at 19:18

create a custom log format that includes $upstream_response_time - if your backend serves it you should get a number of milliseconds to get a response, if nginx serves it internally you should get a dash

share|improve this answer

It's a really dirty hack, but make it so that either Nginx or Thin don't have read permissions to those files. :) That way you'll be able to figure out which one gets an error, hence reading/serving a file.

Alternatively, you should be able to add a custom header to the config block that serves static files. Then you'll be able to see presence of the header or not.

share|improve this answer

Your Answer


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.