nginx serving Django in a subdirectory through uWSGI
<p>I have already gone through some previous threads:
<a href="https://stackoverflow.com/questions/13282938/how-do-i-set-subdirectory-in-nginx-with-django">How do I set subdirectory in nginx with Django</a>
<a href="https://stackoverflow.com/questions/8133063/how-to-deploy-django-under-a-suburl-behind-nginx">how to deploy django under a suburl behind nginx</a>
<a href="https://stackoverflow.com/questions/31151116/serving-flask-app-on-subdirectory-nginx-uwsgi">Serving flask app on subdirectory nginx + uwsgi</a></p>

<p>The basic lesson is that you should only need to configure your site(s-available) to achieve this. I have now tried various permutations of </p>

<pre><code>server {
    listen 80;
    server_name www.example.com;

    location = /favicon.ico { 
        access_log off; 
        log_not_found off; 
    }

    location /static/ {
        root /path/to/project;
    }

    location /project/ {
        root            /path/to/project;
        include         /etc/nginx/uwsgi_params;
        uwsgi_param     SCRIPT_NAME /project;
        uwsgi_modifier1 30;
        uwsgi_param PATH_INFO "$1";
        uwsgi_pass      unix:/tmp/project.sock;
    }
}
</code></pre>

<p>Everything runs perfectly when I define location to be "/" (and remove SCRIPT_NAME, modifier1, PATH_INFO and root doesn't matter. But trying to use a subdirectory always results in Page not found (404):</p>

<pre><code>Request URL:    http://www.example.com/project/project
</code></pre>

<p>(edit) It's ADDING a directory to the request. What am I not figuring out?</p>

<p>(tried forced_script_name - should't have to use this and gives other types of headaches - and uwsgi config setting)</p>

<p>EDIT:</p>

<pre><code>location /project/ {
    root            /path/to/project;
    include         /etc/nginx/uwsgi_params;
    uwsgi_param     SCRIPT_NAME /project;
    uwsgi_pass      unix:/tmp/project.sock;
}
</code></pre>

<p>Does not work ... The socket is there and works when I configure for / - I just can't see what I'm missing.</p>

<p>UPDATE:</p>

<pre><code>location ~ /project(?&lt;path_info&gt;/.*|$) {
    include         /etc/nginx/uwsgi_params;
    uwsgi_pass      unix:/tmp/project.sock;
    uwsgi_param     PATH_INFO $path_info;
    uwsgi_param     SCRIPT_NAME /project;
}
</code></pre>

<p>This loads up the site but all links point to <a href="http://example.com/link/to/something" rel="noreferrer">http://example.com/link/to/something</a> instead of <a href="http://example.com/project/link/to/something" rel="noreferrer">http://example.com/project/link/to/something</a></p>