Multiple django applications with nginx proxy_pass and rewrite

I have one django-admin application with a name myappthat I would like to deploy multiple instances in different physical boxes, one for each client. Nevertheless, I would like to see all of them are available from the same domain mydomain.com/customer1/myapp.

I searched for specific proxy settings and tried a few things suggested on SO, but none of them are suitable for my use ... and since I know very little about nginxand django, I am at a loss!

My current nginx.conf:

server {
    listen 80;
    server_name myserver.com

    location ^~ /static {
        alias /path/to/static/files/;
    }
#    location / {
#        proxy_pass http://127.0.0.1:8001;
#    }
    location ^~ /customer1/myapp/static {
        alias /path/to/static/files/;
    }
    location /customer1/myapp {
        rewrite ^/customer1/myapp/(/?)(.*) /$2 break;
        proxy_pass http://127.0.0.1:8001;
    }
}

, , myserver.com/customer1/myapp/admin. , , nginx url myserver.com/admin, URL-. nginx URL- URL-, 127.0.0.1:8001?

FWIW, gunicorn gunicorn -b 127.0.0.1:8001 -n myapp. / , .

, . , django nginx.conf .

+5
2

, url proxy_pass, :

location ~ ^/customer1/myapp(/?)(.*) {
    proxy_pass http://127.0.0.1:8001/$2;
}

. http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass , nginx uri

+16

:

location /customer1/myapp {
    return 302 $uri/;
}
location /customer1/myapp/ {
    proxy_pass http://127.0.0.1:8001/
}

, proxy_pass, , proxy_redirect default off, 302 /customer1/myapp/ , nginx, , , 404s.

, , (, cookie).

+3

All Articles