title: How to setup nginx + tornado + flask?
body: <p>These are my fully working tornado and flask files:</p>
  
  <p>Tornado:</p>
  
  <pre><code>from flaskk import app
  from tornado.wsgi import WSGIContainer
  from tornado.ioloop import IOLoop
  from tornado.web import FallbackHandler, RequestHandler, Application
  
  class MainHandler(RequestHandler):
    def get(self):
      self.write("This message comes from Tornado ^_^")
  
  tr = WSGIContainer(app)
  
  application = Application([
      (r"/tornado", MainHandler),
      (r".*", FallbackHandler, dict(fallback=tr)),
  ])
  
  if __name__ == '__main__':
      application.listen(5052)
      IOLoop.instance().start()
  </code></pre>
  
  <p>Flask:</p>
  
  <pre><code>from flask import Flask, jsonify
  from flask_restful import Resource, Api
  
  app = Flask(__name__)
  api = Api(app)
  
  class Report(Resource):
      def get(self):
          return 'hello from flask'
  
  api.add_resource(Report, '/report')
  </code></pre>
  
  <p>Now I'm trying to setup nginx in front of tornado.<br>
  My nginx config file is:</p>
  
  <pre><code>worker_processes 3;
  
  error_log  logs/error.;
  
  events {
      worker_connections 1024;
  }
  
  http {
      # Enumerate all the Tornado servers here
      upstream frontends {
          server 127.0.0.1:5052;
      }
  
      include mime.types;
      default_type application/octet-stream;
  
      keepalive_timeout 65;
  
      sendfile on;
  
  
      server {
          listen 5050;
          server_name  localhost;
  
          location / {
              proxy_pass_header Server;
              proxy_set_header Host $http_host;
              proxy_redirect off;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Scheme $scheme;
              proxy_pass http://localhost:5050;
          }
      }
  }
  </code></pre>
  
  <p>When I do a </p>
  
  <blockquote>
    <p>localhost:5050/</p>
  </blockquote>
  
  <p>then I get the nginx welcome page. But when I do </p>
  
  <blockquote>
    <p>localhost:5050/report</p>
  </blockquote>
  
  <p>then I get a 404. Tornado is running on port 5052.<br>
  Why is nginx not calling tornado which thereby should get the result from flask?</p>
  
  <p>Am I missing something here?</p>