Multiple separate projects under nginx

hi ken…
i have a same issue but in a different type !

i want users in ubuntu can run their django projects in /projects dir under the their home directory like /home/user1/projects/proj1, and i want to their projects displaying on e.g domain/<username=user1>/<project_name=proj1>

i wrote this snippet :

location ~ ^/(?<username>[^/]+)/(?<project>[^/]+)/run$ {
   
        proxy_set_header X-Script-Name /$username/$project/run.sock;
        proxy_set_header X-Forwarded-Proto $scheme;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

on some another codes like this with a bit changes.
my most issue is when i use site.com/user1/proj1/ i can see / (django main page) but when i change the url to site.com/user1/proj1/admin 404 raised from nginx or django!
can u help me to solve this, [users deploy and run their projects in home dir with unix socket and i want that to work !!! ]

Welcome @vahidnadarkhani !

I’ve moved your question to create a new topic, as it really is a different issue.

It’s also an interesting idea - one I haven’t worked with before. I’m going to need to check a couple things and get back to you.

Superficially, I’m going to say that you will either need to set the SCRIPT_NAME environment variable in the requests or use the FORCE_SCRIPT_NAME setting to ensure that each instance knows it’s running under /<user>/<project>/

I’m just not sure whether you can do this with an nginx directive or if it’s something you will need to have each person add to their settings.
e.g. FORCE_SCRIPT_NAME=/user1/proj1/

thank you ken.
i’m waiting for your response and i hope u can solve it …

About the issues you asked:
i checked both of them .
setted FORCE_SCRIPT_NAME in django setting and/or using SCRIPT_NAME in nginx cfg file.

also if needed:
i’m using gunicorn .

Are the people running their projects using Gunicorn? (If so, see FAQ — Gunicorn 23.0.0 documentation)

If they’re using uWSGI, then see the manage-script-name option.

If you’ve made these settings changes and they don’t work, please post the actual nginx configuration block and settings made, and provide details about the results.

To diagnose this further, it might be helpful to see exactly what is being passed from nginx to the wsgi server. This could include tracing the actual wsgi packet being forwarded from nginx to the application.