Running Zegami in a webserver directory

Sometimes it is desirable to namespace the different apps installed on a single webserver so that the urls look like:

http://myserver.com/           #index page
http://myserver.com/myapp/     #another app
http://myserver.com/zegami/    #zegami start page

In order to configure this set-up you will need to change the settings for both uwsgi and nginx.

Full versions of the files are available here:

/opt/zegami/conf/nginx.conf

/etc/supervisor/conf.d/supervisor_uwsgi.conf

NGINX config details

The config for NGINX is as for a standard install except for changes to these directives:

In the file:

/opt/zegami/conf/nginx.conf (formerly /opt/zegami_python/anaconda/etc/nginx/nginx.conf)

The 2 sections that look like this (http and https)

location / {
    try_files $uri @yourapplication;
}
location @yourapplication {
    include uwsgi_params;
    uwsgi_pass unix:///tmp/zegami-uwsgi.sock;
}

Should be changed to

location /zegami {                      #change the URL path
    try_files $uri @yourapplication;
}
location @yourapplication {
    include uwsgi_params;
    uwsgi_pass unix:///tmp/zegami-uwsgi.sock;
    include uwsgi_params;                #add a script name parameter
    uwsgi_param SCRIPT_NAME /zegami;
    uwsgi_modifier1 30;                  #give uwsgi permission 
}

uWSGI config details

In the case of uWSGI, the --module option is replaced with a --mount option

In the file

/etc/supervisor/conf.d/supervisor_uwsgi.conf

The line

--module=dzapi.app.application:app

Should be changed to

--manage-script-name
--mount=/zegami=dzapi.app.application:app

Following this run:

sudo supervisorctl reread && sudo supervisorctl restart all

If running nginx outside supervisor then restart or reload nginx