title: Django + uWSGI + nginx url mapping
body: <p>I want to run Django with uWSGI behind a NGINX.</p>
  
  <p>I will use Django as a API service which should live on this link:
  project.test/api
  The Django project itself is blank (1.9.6), just created a app, migrated and created a superuser.</p>
  
  <p>My Project structure looks like this:<br>
  /vagrant/api/here-lives-whole-django<br>
  /vagrant/api/uwsgi_params<br>
  /vagrant/frontend/some-frontend-work-seperated-from-django<br></p>
  
  <p>My NGINX setup looks like this:</p>
  
  <pre><code>upstream testing {
      server 127.0.0.1:8000;
  }
  
  server {
      listen   80;
  
      server_name www.testing.test;
  
      charset  utf-8;
  
      client_max_body_size  75M;
  
      access_log  /var/log/nginx/www.testing.test.access.log;
      error_log  /var/log/nginx/www.testing.test.error.log;
  
      location /api/ {
          include /vagrant/api/uwsgi_params;
          uwsgi_pass testing;
      }
  
      location / {
          root /vagrant/frontend;
      }
  }
  </code></pre>
  
  <p>The uwsgi_params file:</p>
  
  <pre><code>uwsgi_param  QUERY_STRING       $query_string;
  uwsgi_param  REQUEST_METHOD     $request_method;
  uwsgi_param  CONTENT_TYPE       $content_type;
  uwsgi_param  CONTENT_LENGTH     $content_length;
  
  uwsgi_param  REQUEST_URI        $request_uri;
  uwsgi_param  PATH_INFO          $document_uri;
  uwsgi_param  DOCUMENT_ROOT      $document_root;
  uwsgi_param  SERVER_PROTOCOL    $server_protocol;
  uwsgi_param  REQUEST_SCHEME     $scheme;
  uwsgi_param  HTTPS              $https if_not_empty;
  
  uwsgi_param  REMOTE_ADDR        $remote_addr;
  uwsgi_param  REMOTE_PORT        $remote_port;
  uwsgi_param  SERVER_PORT        $server_port;
  uwsgi_param  SERVER_NAME        $server_name;
  </code></pre>
  
  <p>My Django url pattern:</p>
  
  <pre><code>urlpatterns = [
      url(r'^admin/', admin.site.urls),
  ]
  </code></pre>
  
  <p>Atm. Im running Django with following command:<br>
  uwsgi --socket :8000 --wsgi-file wsgi.py</p>
  
  <p>Im able to reach Django but when I try to access<br>
  www.testing.test/api/admin<br>
  I get a 404 (debug from Django).</p>
  
  <pre><code>Page not found (404)
  Request Method: GET
  Request URL:    http://www.testing.test/api/admin
  Using the URLconf defined in testing.urls, Django tried these URL patterns, in this order:
  ^admin/
  The current URL, api/admin, didn't match any of these.
  </code></pre>
  
  <p>I know it will be something very simple for people who are used to this stuff, forgive me because Im new.</p>
  
  <p>Ps. I found some similar questions where people worked with</p>
  
  <pre><code>uwsgi_param SCRIPT_NAME /api;
  uwsgi_modifier1 30; 
  </code></pre>
  
  <p>But this just made my Django tell me a 404 with</p>
  
  <pre><code>Request URL:    http://www.testing.test/api/api/admin
  </code></pre>
  
  <p>when I requested</p>
  
  <pre><code>Request URL:    http://www.testing.test/api/admin
  </code></pre>