title: 404 when trying to get index from Flask app running on nginx through uWSGI
body: <p>I am trying to run a Flask application on nginx with uWSGI on my Ubuntu droplet following <a href="https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-14-04" rel="nofollow">this tutorial</a>.</p>
  
  <p>All the intermediate tests work fine until the very last one, where it's time to test all components working together.</p>
  
  <p>Here is where the Flask app lives.</p>
  
  <pre><code>dsaltares@saltares:/home/dsaltares/conjugate/site: tree .
  .
  ├── conjugate.ini
  ├── conjugate.py
  ├── conjugate.sock
  ├── wsgi.py
  </code></pre>
  
  <p>The relevant parts in <code>conjugate.py</code>
      bp = Blueprint('bp', <strong>name</strong>, template_folder='templates')</p>
  
  <pre><code>application = Flask(__name__)
  application.config['APPLICATION_ROOT'] = '/conjugate'
  application.register_blueprint(bp, url_prefix='conjugate')
  
  @bp.route('/')
  def index():
      return render_template('index.html') 
  </code></pre>
  
  <p>The <code>wsgi.py</code> file</p>
  
  <pre><code>from conjugate import application
  
  if __name__ == '__main__':
      application.run()
  </code></pre>
  
  <p>The <code>conjugate.ini</code> file</p>
  
  <pre><code>[uwsgi]
  module = wsgi
  
  master = true
  processes = 5
  
  socket = conjugate.sock
  chmod-socket = 660
  vacuum = true
  
  die-on-term = true
  uid = dsaltares
  gid = www-data
  </code></pre>
  
  <p>Running <code>uwsgi --socket 0.0.0.0:8000 --protocol=http -w wsgi</code> works perfectly fine. I can access the app from my laptop.</p>
  
  <p>The <code>/etc/init/conjugate.conf</code> file</p>
  
  <pre><code>description "uWSGI server instance configured to serve conjugate"
  
  start on runlevel [2345]
  stop on runlevel [!2345]
  
  setuid dsaltares
  setgid www-data
  
  env PATH=/home/dsaltares/conjugate/env/bin
  chdir /home/dsaltares/conjugate/site
  exec uwsgi --ini conjugate.ini
  </code></pre>
  
  <p>Now the <code>/etc/nginx/sites-available/default</code> file</p>
  
  <pre><code>server {
          listen 80;
  
          fastcgi_buffers 16 16k;
          fastcgi_buffer_size 32k;
  
          root /usr/share/nginx/html;
  
          index index.html index.htm index.nginx-debian.html index.php;
  
          server_name example.com;
  
          location = / {
              # Redirect to /blog
              return 301 http://example.com/blog;
          }
  
          location /blog/ {
              try_files $uri $uri/ /blog/index.php?$args;
          }
  
          location ~ /\.ht {
              deny all;
          }
  
          location ~ \.php$ {
              ...
          }
  
          location /conjugate/ {
              include uwsgi_params;
              uwsgi_pass unix:/home/dsaltares/conjugate/site/conjugate.sock;
          }
  }
  </code></pre>
  
  <p>After <code>sudo service conjugate restart</code> and <code>sudo service nginx restart</code> and trying to access <code>http://example.com/conjugate</code> I get:</p>
  
  <pre><code>404 The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.
  </code></pre>
  
  <p><code>sudo tail -f /var/log/nginx/error.log</code> doesn't show any errors.</p>
  
  <p>Any ideas? Thank you very much</p>