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 have a directory structure I want to serve, that contains files as binary and some meta-information about them as json. for some directories, I need to compute some things on the fly and serve that. I want to compute and serve that information using tornado.

Here is an example:

> ls /manufacturers/*

> wget http://localhost/manufactures/audi.json
  returns the json file using nginx static serving
> wget http://localhost/?diesel
  returns a json file with manufactures that 
  create cars with diesel engines computed by and using tornado
share|improve this question
up vote 2 down vote accepted

If your use-case is "serve static files if they exist, otherwise send everything to tornado", you can do that with try_files:

upstream upstream_tornado {
    # ...or wherever
server {
    listen 80;
    server_name localhost;
    root /path/to/wherever;

    try_files  $uri @tornado;

    location @tornado {
        proxy_pass http://upstream_tornado;
        # Other proxy stuff e.g. proxy_set_header
share|improve this answer
Using this right now. Works like a charm. – AME Feb 25 '13 at 15:49

You can check with nginx whether ?diesel is being called by looking for $arg_diesel in the location = / block.

location = / {

    if ( $arg_diesel ) {
        proxy_pass http://tornado;


location = / is not the same as the location /. location = / will only be called for requests that aren't in a folder such /?diesel, but not /somepath/?diesel whereas the location / will match everything.


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.