Trying to add second project on Nginx configuration

Please, don’t do this

Please don’t do this

Suggestions:

  • Change STATIC_ROOT to be of the pattern /var/www/html/<project name>
    i.e., either STATIC_ROOT=/var/www/html/django_referral or STATIC_ROOT=/var/www/html/domestic_voicelogging/ as appropriate.

  • Ensure that /var/www/html exists, is owned by www-data and group www-data, and has the “sticky bit” set on the group.

    • mkdir -p /var/www/html
    • chown www-data:www-data /var/www/html
    • chmod 2775 /var/www/html
  • Run collectstatic, verifying that each project has deployed the static files to the proper directory.

  • Change your nginx configuration for these static directories.

  • The URLs being issued are not including the prefix for the projects. Change STATIC_URL to be /domestic_voicelogging/static/ or /django_referral/static/ as appropriate.

Restart everything.

Using your browser, issue a request for https://..../django_referral/static/CSS/loginStyle.9b8774737cdc.css (or domestic_voicelogging, whichever is appropriate) and report the results - including any error messages in the nginx log.

This wont affect whitenoise?

Also where should i create this directory where staticfiles were/was, so should i replace?

this is my settings.py:

STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / "staticfiles"
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'djangoprogram', 'static'),
]

STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"

You’ve got your nginx configuration to not use whitenoise. That’s the purpose of those two static directory aliases you have defined.

The STATICFILES_DIRS setting shows a source of static files in addition to your apps for collectstatic to reference, this does not change.

Side note: Handling static files in a production environment is a common deployment-related issue here. There are many threads discussing it from different aspects.

For some additional information and another perspective, you may wish to read the threads at Restrict image access, and Django deployment. (They are talking about different issues, but a lot of the general information applies.)

@KenWhitesell
Mornings

I created the DIR but when i tried to add the permission i got this:

(venv) [marco@mydjangoserver django_referral]$ chown www-data:www-data /var/www/html
chmod 2775 /var/www/html
chown: invalid user: ‘www-data:www-data’
chmod: changing permissions of '/var/www/html': Operation not permitted
(venv) [marco@mydjangoserver django_referral]$ ps aux | grep nginx
root     1469389  0.0  0.1  10112  1484 ?        Ss   08:45   0:00 nginx: master process /usr/sbin/nginx
nginx    1469390  0.0  0.7  14380  5836 ?        S    08:45   0:00 nginx: worker process
marco    1469881  0.0  0.2   3876  1920 pts/0    S+   09:35   0:00 grep --color=auto nginx
(venv) [marco@mydjangoserver django_referral]$

Oops, sorry, that should be marco:www-data

You will need to be root to issue that comand, so in your case, it would be sudo chown ...

(I’m a little surprised you didn’t encounter this on the mkdir command, and you’ll also need to do it for the chmod command.)

@KenWhitesell
Okay so have created the static root and url. also i have the two /var/www/html/paths:

(venv_voicelogging) [marco@mydjangoserver domestic_voicelogging]$ ls -l /var/www/html/domestic_voicelogging/
total 28
drwxr-sr-x. 2 marco www-data  4096 Sep 12 15:09 CSS
drwxr-sr-x. 2 marco www-data  4096 Sep 12 15:09 JS
drwxr-sr-x. 5 marco www-data  4096 Sep 12 14:42 admin
drwxr-sr-x. 2 marco www-data  4096 Sep 12 14:42 images
-rw-r--r--. 1 marco www-data 10815 Sep 12 15:09 staticfiles.json
(venv_voicelogging) [marco@mydjangoserver domestic_voicelogging]$ ls -l /var/www/html/django_referral/
total 28
drwxr-sr-x. 2 marco www-data  4096 Sep 12 15:08 CSS
drwxr-sr-x. 2 marco www-data  4096 Sep 12 15:08 JS
drwxr-sr-x. 5 marco www-data  4096 Sep 12 13:47 admin
drwxr-sr-x. 2 marco www-data  4096 Sep 12 13:47 images
-rw-r--r--. 1 marco www-data 11880 Sep 12 15:08 staticfiles.json
(venv_voicelogging) [marco@mydjangoserver domestic_voicelogging]$

Static settings for domestic_voicelogging:

STATIC_URL = '/domestic_voicelogging/static/'
STATIC_ROOT = '/var/www/html/domestic_voicelogging/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'voiceloggingApp', 'static'),
]

STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"

Static settings for django_referral:

STATIC_URL = '/django_referral/static/'
STATIC_ROOT = '/var/www/html/django_referral'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'djangoprogram', 'static'),
]

STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"

Gunicorn

Domestic_voicelogging sock and service:

Service:
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=marco
Group=www-data
WorkingDirectory=/home/marco/domestic_voicelogging
ExecStart=/home/marco/domestic_voicelogging/venv_voicelogging/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          domestic_voicelogging.wsgi:application

[Install]
WantedBy=multi-user.target

Socket:

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock
SocketUser=marco
SocketGroup=www-data
SocketMode=0660

[Install]
WantedBy=sockets.target

(venv_voicelogging) [marco@mydjangoserver django_referral]$ sudo systemctl status gunicorn
● gunicorn.service - gunicorn daemon
     Loaded: loaded (/etc/systemd/system/gunicorn.service; enabled; preset: disabled)
     Active: active (running) since Thu 2024-09-12 14:56:50 SAST; 21min ago
TriggeredBy: ● gunicorn.socket
   Main PID: 1474088 (gunicorn)
      Tasks: 4 (limit: 4692)
     Memory: 95.0M
        CPU: 1.143s
     CGroup: /system.slice/gunicorn.service
             ├─1474088 /home/marco/domestic_voicelogging/venv_voicelogging/bin/python3 /home/marco/domestic_voicelogging/venv_voicelogging/bin/gunicorn --access-logfile - --workers 3 --bin>
             ├─1474089 /home/marco/domestic_voicelogging/venv_voicelogging/bin/python3 /home/marco/domestic_voicelogging/venv_voicelogging/bin/gunicorn --access-logfile - --workers 3 --bin>
             ├─1474090 /home/marco/domestic_voicelogging/venv_voicelogging/bin/python3 /home/marco/domestic_voicelogging/venv_voicelogging/bin/gunicorn --access-logfile - --workers 3 --bin>
             └─1474091 /home/marco/domestic_voicelogging/venv_voicelogging/bin/python3 /home/marco/domestic_voicelogging/venv_voicelogging/bin/gunicorn --access-logfile - --workers 3 --bin>

Sep 12 14:56:50 mydjangoserver.co.za systemd[1]: Started gunicorn daemon.
Sep 12 14:56:50 mydjangoserver.co.za gunicorn[1474088]: [2024-09-12 14:56:50 +0200] [1474088] [INFO] Starting gunicorn 22.0.0
Sep 12 14:56:50 mydjangoserver.co.za gunicorn[1474088]: [2024-09-12 14:56:50 +0200] [1474088] [INFO] Listening at: unix:/run/gunicorn.sock (1474088)
Sep 12 14:56:50 mydjangoserver.co.za gunicorn[1474088]: [2024-09-12 14:56:50 +0200] [1474088] [INFO] Using worker: sync
Sep 12 14:56:50 mydjangoserver.co.za gunicorn[1474089]: [2024-09-12 14:56:50 +0200] [1474089] [INFO] Booting worker with pid: 1474089
Sep 12 14:56:50 mydjangoserver.co.za gunicorn[1474090]: [2024-09-12 14:56:50 +0200] [1474090] [INFO] Booting worker with pid: 1474090
Sep 12 14:56:50 mydjangoserver.co.za gunicorn[1474091]: [2024-09-12 14:56:50 +0200] [1474091] [INFO] Booting worker with pid: 1474091
lines 1-21/21 (END)

Django_referral sock and service:

Service:

[Unit]
Description=gunicorn daemon for django_referral
Requires=django_referral.socket
After=network.target

[Service]
User=marco
Group=www-data
WorkingDirectory=/home/marco/django_referral
ExecStart=/home/marco/django_referral/venv_referral/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/django_referral.sock \
          django_referral.wsgi:application

[Install]
WantedBy=multi-user.target

Socket:

[Unit]
Description=gunicorn socket for django_referral

[Socket]
ListenStream=/run/django_referral.sock
SocketUser=marco
SocketGroup=www-data
SocketMode=0660

[Install]
WantedBy=sockets.target

(venv_voicelogging) [marco@mydjangoserver django_referral]$ sudo systemctl status django_referral
● django_referral.service - gunicorn daemon for django_referral
     Loaded: loaded (/etc/systemd/system/django_referral.service; enabled; preset: disabled)
     Active: active (running) since Thu 2024-09-12 15:20:41 SAST; 8s ago
TriggeredBy: ● django_referral.socket
   Main PID: 1474919 (gunicorn)
      Tasks: 4 (limit: 4692)
     Memory: 91.3M
        CPU: 884ms
     CGroup: /system.slice/django_referral.service
             ├─1474919 /home/marco/django_referral/venv_referral/bin/python3 /home/marco/django_referral/venv_referral/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/django_r>
             ├─1474920 /home/marco/django_referral/venv_referral/bin/python3 /home/marco/django_referral/venv_referral/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/django_r>
             ├─1474921 /home/marco/django_referral/venv_referral/bin/python3 /home/marco/django_referral/venv_referral/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/django_r>
             └─1474922 /home/marco/django_referral/venv_referral/bin/python3 /home/marco/django_referral/venv_referral/bin/gunicorn --access-logfile - --workers 3 --bind unix:/run/django_r>

Sep 12 15:20:41 mydjangoserver.co.za systemd[1]: Started gunicorn daemon for django_referral.
Sep 12 15:20:41 mydjangoserver.co.za gunicorn[1474919]: [2024-09-12 15:20:41 +0200] [1474919] [INFO] Starting gunicorn 23.0.0
Sep 12 15:20:41 mydjangoserver.co.za gunicorn[1474919]: [2024-09-12 15:20:41 +0200] [1474919] [INFO] Listening at: unix:/run/django_referral.sock (1474919)
Sep 12 15:20:41 mydjangoserver.co.za gunicorn[1474919]: [2024-09-12 15:20:41 +0200] [1474919] [INFO] Using worker: sync
Sep 12 15:20:41 mydjangoserver.co.za gunicorn[1474920]: [2024-09-12 15:20:41 +0200] [1474920] [INFO] Booting worker with pid: 1474920
Sep 12 15:20:41 mydjangoserver.co.za gunicorn[1474921]: [2024-09-12 15:20:41 +0200] [1474921] [INFO] Booting worker with pid: 1474921
Sep 12 15:20:41 mydjangoserver.co.za gunicorn[1474922]: [2024-09-12 15:20:41 +0200] [1474922] [INFO] Booting worker with pid: 1474922
lines 1-21/21 (END)

Nginx config:

server {
    listen 80;
    server_name 41.76.110.165;

    # Static files for Project 1
    location /domestic_voicelogging/static/ {
        alias /var/www/html/domestic_voicelogging/;
    }

    # Static files for Project 2
    location /django_referral/static/ {
        alias /var/www/html/django_referral/;
    }

    # Application requests for Project 1
    location /domestic_voicelogging/ {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }

    # Application requests for Project 2
    location /django_referral/ {
        include proxy_params;
        proxy_pass http://unix:/run/django_referral.sock;
    }

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

Status:
(venv_voicelogging) [marco@mydjangoserver django_referral]$ sudo systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
     Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; preset: disabled)
     Active: active (running) since Thu 2024-09-12 15:21:39 SAST; 10s ago
    Process: 1474946 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
    Process: 1474948 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
    Process: 1474949 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
   Main PID: 1474950 (nginx)
      Tasks: 2 (limit: 4692)
     Memory: 2.0M
        CPU: 34ms
     CGroup: /system.slice/nginx.service
             ├─1474950 "nginx: master process /usr/sbin/nginx"
             └─1474951 "nginx: worker process"

Sep 12 15:21:39 mydjangoserver.co.za systemd[1]: Starting The nginx HTTP and reverse proxy server...
Sep 12 15:21:39 mydjangoserver.co.za nginx[1474948]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Sep 12 15:21:39 mydjangoserver.co.za nginx[1474948]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Sep 12 15:21:39 mydjangoserver.co.za systemd[1]: Started The nginx HTTP and reverse proxy server.

When i try to acces the site through url i get 404. Here are the access and erro logs for nginx:

(venv_voicelogging) [marco@mydjangoserver django_referral]$ sudo tail -f /var/log/nginx/error.log
sudo tail -f /var/log/nginx/access.log
2024/09/12 14:48:11 [error] 1473408#1473408: *36 upstream prematurely closed connection while reading response header from upstream, client: 185.16.39.118, server: 41.76.110.165, request: "GET / HTTP/1.1", upstream: "http://unix:/run/django_referral.sock:/", host: "41.76.110.165"
2024/09/12 15:04:14 [error] 1473872#1473872: *2 "/usr/share/nginx/html/djangoprogram/login/index.html" is not found (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /djangoprogram/login/?next=/djangoprogram/home/ HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/djangoprogram/login/?next=/djangoprogram/home/"
2024/09/12 15:04:32 [error] 1473872#1473872: *3 "/usr/share/nginx/html/djangoprogram/login/index.html" is not found (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /djangoprogram/login/ HTTP/1.1", host: "41.76.110.165"
2024/09/12 15:05:25 [error] 1473872#1473872: *4 open() "/usr/share/nginx/html/admin/assets/js/views/login.js" failed (2: No such file or directory), client: 5.189.172.158, server: 41.76.110.165, request: "GET /admin/assets/js/views/login.js HTTP/1.0", host: "41.76.110.165"
2024/09/12 15:09:43 [error] 1473872#1473872: *5 "/usr/share/nginx/html/djangoprogram/login/index.html" is not found (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "POST /djangoprogram/login/ HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/djangoprogram/login/?next=/djangoprogram/home/"
2024/09/12 15:14:06 [error] 1473872#1473872: *6 open() "/usr/share/nginx/html/api/env" failed (2: No such file or directory), client: 185.130.44.86, server: 41.76.110.165, request: "GET /api/env HTTP/1.1", host: "mail.vmcloudhost.interdevsystems.co.za"
2024/09/12 15:14:07 [error] 1473872#1473872: *7 open() "/usr/share/nginx/html/admin/actuator/env" failed (2: No such file or directory), client: 185.130.44.86, server: 41.76.110.165, request: "GET /admin/actuator/env HTTP/1.1", host: "mail.vmcloudhost.interdevsystems.co.za"
2024/09/12 15:14:08 [error] 1473872#1473872: *8 open() "/usr/share/nginx/html/admin/env;" failed (2: No such file or directory), client: 185.130.44.86, server: 41.76.110.165, request: "GET /admin/env; HTTP/1.1", host: "mail.vmcloudhost.interdevsystems.co.za"
2024/09/12 15:22:51 [error] 1474951#1474951: *1 "/usr/share/nginx/html/djangoprogram/login/index.html" is not found (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /djangoprogram/login/?next=/djangoprogram/home/ HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/djangoprogram/login/?next=/djangoprogram/home/"
2024/09/12 15:22:55 [error] 1474951#1474951: *1 "/usr/share/nginx/html/djangoprogram/login/index.html" is not found (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /djangoprogram/login/ HTTP/1.1", host: "41.76.110.165"
^C
5.189.172.158 - - [12/Sep/2024:14:50:13 +0200] "\x16\x03\x01\x01\xA8\x01\x00\x01\xA4\x03\x03?\xBE^'lW\xBB\xD8\x86B\xDC\xD8\xF7\xA9\xAA\xA9\xC4\x8A\xF5\x08\xC8>\xC8\xA4\xBB\xAA]\xCA\x99\x19\xAD\x02 \xF2\x16\x86\x9B|\x1E \xD3\xE6i\x7F@\xCE\x98\xA2\x95\x8B\xC0\x15\x87\x8Cb;+*b\xE1I\xC0q\x959\x00\xC6\x13\x01\x13\x02\x13\x03\x13\x04\x13\x05\xC0,\xC00\x00\xA3\x00\x9F\xCC\xA9\xCC\xA8\xCC\xAA\xC0\xAF\xC0\xAD\xC0\xA3\xC0\x9F\xC0]\xC0a\xC0W\xC0S\x00\xA7\xC0+\xC0/\x00\xA2\x00\x9E\xC0\xAE\xC0\xAC\xC0\xA2\xC0\x9E\xC0\x5C\xC0`\xC0V\xC0R\x00\xA6\xC0$\xC0(\x00k\x00j\xC0s\xC0w\x00\xC4\x00\xC3\x00m\x00\xC5\xC0#\xC0'\x00g\x00@\xC0r\xC0v\x00\xBE\x00\xBD\x00l\x00\xBF\xC0" 400 157 "-" "-" "-"
105.245.236.240 - - [12/Sep/2024:15:04:14 +0200] "GET /djangoprogram/login/?next=/djangoprogram/home/ HTTP/1.1" 404 153 "http://41.76.110.165/djangoprogram/login/?next=/djangoprogram/home/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0" "-"
105.245.236.240 - - [12/Sep/2024:15:04:32 +0200] "GET /djangoprogram/login/ HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0" "-"
5.189.172.158 - - [12/Sep/2024:15:05:25 +0200] "GET /admin/assets/js/views/login.js HTTP/1.0" 404 153 "-" "xfa1" "-"
105.245.236.240 - - [12/Sep/2024:15:09:43 +0200] "POST /djangoprogram/login/ HTTP/1.1" 404 153 "http://41.76.110.165/djangoprogram/login/?next=/djangoprogram/home/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0" "-"
185.130.44.86 - - [12/Sep/2024:15:14:06 +0200] "GET /api/env HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Kubuntu; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0" "-"
185.130.44.86 - - [12/Sep/2024:15:14:07 +0200] "GET /admin/actuator/env HTTP/1.1" 404 555 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.7 Safari/537.36" "-"
185.130.44.86 - - [12/Sep/2024:15:14:08 +0200] "GET /admin/env; HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6.1 Safari/605.1.15" "-"
105.245.236.240 - - [12/Sep/2024:15:22:51 +0200] "GET /djangoprogram/login/?next=/djangoprogram/home/ HTTP/1.1" 404 153 "http://41.76.110.165/djangoprogram/login/?next=/djangoprogram/home/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0" "-"
105.245.236.240 - - [12/Sep/2024:15:22:55 +0200] "GET /djangoprogram/login/ HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0" "-"
^C
(venv_voicelogging) [marco@mydjangoserver django_referral]$

i see a problem with my sock files:

(venv_referral) [marco@mydjangoserver django_referral]$ ls -l /run/gunicorn.sock
ls -l /run/django_referral.sock
srw-rw-rw-. 1 marco www-data 0 Jul  9 09:37 /run/gunicorn.sock
srw-rw----. 1 nginx www-data 0 Sep 12 08:37 /run/django_referral.sock

@KenWhitesell

Made a lot of progress both projects are accessible on the site. There is a problem with the css loading. This is the error log:

(venv_referral) [marco@mydjangoserver django_referral]$ ls -l /run/gunicorn.sock
ls -l /run/django_referral.sock
srw-rw----. 1 nginx www-data 0 Jul  9 09:37 /run/gunicorn.sock
srw-rw----. 1 nginx www-data 0 Sep 12 08:37 /run/django_referral.sock
(venv_referral) [marco@mydjangoserver django_referral]$ sudo systemctl restart gunicorn
sudo systemctl restart nginx
(venv_referral) [marco@mydjangoserver django_referral]$ sudo systemctl restart django_referral
(venv_referral) [marco@mydjangoserver django_referral]$ sudo tail -f /var/log/nginx/error.log
2024/09/12 16:27:30 [crit] 1475627#1475627: *1 connect() to unix:/run/django_referral.sock failed (13: Permission denied) while connecting to upstream, client: 105.245.236.240, server: 41.76.110.165, request: "GET /djangoprogram/login HTTP/1.1", upstream: "http://unix:/run/django_referral.sock:/djangoprogram/login", host: "41.76.110.165"
2024/09/12 16:29:14 [crit] 1475627#1475627: *3 connect() to unix:/run/gunicorn.sock failed (13: Permission denied) while connecting to upstream, client: 105.245.236.240, server: 41.76.110.165, request: "GET /voicelogging/login HTTP/1.1", upstream: "http://unix:/run/gunicorn.sock:/voicelogging/login", host: "41.76.110.165"
2024/09/12 16:29:20 [crit] 1475627#1475627: *5 connect() to unix:/run/gunicorn.sock failed (13: Permission denied) while connecting to upstream, client: 105.245.236.240, server: 41.76.110.165, request: "GET /voicelogging/login HTTP/1.1", upstream: "http://unix:/run/gunicorn.sock:/voicelogging/login", host: "41.76.110.165"
2024/09/12 16:32:20 [error] 1475627#1475627: *7 open() "/usr/share/nginx/html/cgi-bin/luci/;stok=/locale" failed (2: No such file or directory), client: 141.255.160.234, server: 41.76.110.165, request: "GET /cgi-bin/luci/;stok=/locale HTTP/1.1", host: "41.76.110.165:80"
2024/09/12 16:32:53 [error] 1475764#1475764: *3 open() "/usr/share/nginx/html/domestic_voicelogging/static/CSS/login.css" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /domestic_voicelogging/static/CSS/login.css HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/voicelogging/login/"
2024/09/12 16:32:53 [error] 1475764#1475764: *3 open() "/usr/share/nginx/html/domestic_voicelogging/static/images/logo.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /domestic_voicelogging/static/images/logo.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/voicelogging/login/"
2024/09/12 16:32:54 [error] 1475764#1475764: *3 open() "/usr/share/nginx/html/domestic_voicelogging/static/images/favicon.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /domestic_voicelogging/static/images/favicon.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/voicelogging/login/"
2024/09/12 16:33:08 [error] 1475764#1475764: *3 open() "/usr/share/nginx/html/django_referral/static/CSS/loginStyle.css" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /django_referral/static/CSS/loginStyle.css HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/djangoprogram/login/"
2024/09/12 16:33:09 [error] 1475764#1475764: *3 open() "/usr/share/nginx/html/django_referral/static/images/LogoText.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /django_referral/static/images/LogoText.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/djangoprogram/login/"
2024/09/12 16:33:09 [error] 1475764#1475764: *3 open() "/usr/share/nginx/html/django_referral/static/images/LogoS.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /django_referral/static/images/LogoS.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/djangoprogram/login/"
^C
(venv_referral) [marco@mydjangoserver django_referral]$ sudo chmod -R 755 /var/www/html/domestic_voicelogging/
sudo chmod -R 755 /var/www/html/django_referral/
(venv_referral) [marco@mydjangoserver django_referral]$ sudo systemctl restart nginx
(venv_referral) [marco@mydjangoserver django_referral]$

this is my new Nginx config:

server {
    listen 80;
    server_name 41.76.110.165;

    # Static files for Project 1
    location /voicelogging/static/ {
        alias /var/www/html/domestic_voicelogging/;
    }

    # Static files for Project 2
    location /djangoprogram/static/ {
        alias /var/www/html/django_referral/;
    }

    # Application requests for Project 1
    location /voicelogging/ {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }

    # Application requests for Project 2
    location /djangoprogram/ {
        include proxy_params;
        proxy_pass http://unix:/run/django_referral.sock;
    }

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

Did you run python manage.py collectstatic ?

Try this:

sudo chown marco:www-data /run/gunicorn.sock

sudo chown marco:www-data /run/django_referral.sock

This configuration file is not matching the logs. There’s something fundamentally mismatched with your nginx configuration.

For example:

You’re not showing any configuration referencing an access to files under /usr/share/nginx

What I do see - your URL being referenced is:
GET /domestic_voicelogging/static/CSS/login.css

But you now have:

which is a change from earlier, and needs to match your STATIC_URL setting.

@anefta

Hi, yes i believe did run collectstatic:

(venv_referral) [marco@mydjangoserver django_referral]$ python manage.py collectstatic

You have requested to collect static files at the destination
location as specified in your settings:

    /var/www/html/django_referral

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Found another file with the destination path 'JS/searchAgents.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'JS/searchGrid.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'JS/baseTimeout.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'JS/searchQuotes.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'JS/reportSearch.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'JS/searchPolicy.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'images/LogoText.png'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'images/horizon.jpeg'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'images/waterSplash.jpeg'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'images/beach.jpeg'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'images/Swirl.png'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'images/LogoS.png'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'images/LogoGif.gif'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'images/LogoM.png'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'images/favicon.ico'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/addQuoteStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/viewAgentStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/quoteGridStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/gridStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/homeStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/agentProfileStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/navabrStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/prospectProfileStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/addPolicyStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/loginStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/addAgentStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/addProspectStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/declinedStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.

0 static files copied to '/var/www/html/django_referral', 153 unmodified, 408 post-processed.
(venv_referral) [marco@mydjangoserver django_referral]$ deactivate
[marco@mydjangoserver django_referral]$ cd ..
[marco@mydjangoserver ~]$ cd domestic_voicelogging/
[marco@mydjangoserver domestic_voicelogging]$ source venv_voicelogging/bin/activate
(venv_voicelogging) [marco@mydjangoserver domestic_voicelogging]$ python manage.py collectstatic

You have requested to collect static files at the destination
location as specified in your settings:

    /var/www/html/domestic_voicelogging

This will overwrite existing files!
Are you sure you want to do this?

Type 'yes' to continue, or 'no' to cancel: yes
Found another file with the destination path 'JS/applicationScript.js'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'images/favicon.png'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'images/logo.png'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'images/Login.png'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'images/b1.png'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/homeStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/searchStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/applicationStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/reportStyle.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/login.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'CSS/claim.css'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.

0 static files copied to '/var/www/html/domestic_voicelogging', 136 unmodified, 370 post-processed.

Changed the user from ‘nginx’ to ‘marco’. Getting 502 bad Gateway now:

(venv_voicelogging) [marco@mydjangoserver domestic_voicelogging]$ ls -l /run/gunicorn.sock
srw-rw----. 1 nginx www-data 0 Jul  9 09:37 /run/gunicorn.sock
(venv_voicelogging) [marco@mydjangoserver domestic_voicelogging]$ ls -l /run/django_referral.sock
srw-rw----. 1 nginx www-data 0 Sep 12 08:37 /run/django_referral.sock
(venv_voicelogging) [marco@mydjangoserver domestic_voicelogging]$ sudo chown marco:www-data /run/gunicorn.sock

sudo chown marco:www-data /run/django_referral.sock
[sudo] password for marco:
(venv_voicelogging) [marco@mydjangoserver domestic_voicelogging]$ ls -l /run/gunicorn.sock
srw-rw----. 1 marco www-data 0 Jul  9 09:37 /run/gunicorn.sock
(venv_voicelogging) [marco@mydjangoserver domestic_voicelogging]$ ls -l /run/django_referral.sock
srw-rw----. 1 marco www-data 0 Sep 12 08:37 /run/django_referral.sock

Changed it back to user ‘nginx’ and it works now don’t really know why …

@KenWhitesell

Update, this is my nginx config:

server {
    listen 80;
    server_name 41.76.110.165;

    # Static files for Project 1
    location /domestic_voicelogging/static/ {
        alias /var/www/html/domestic_voicelogging/;
    }

    # Static files for Project 2
    location /django_referral/static/ {
        alias /var/www/html/django_referral/;
    }

    # Application requests for Project 1
    location /voicelogging/ {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }

    # Application requests for Project 2
    location /djangoprogram/ {
        include proxy_params;
        proxy_pass http://unix:/run/django_referral.sock;
    }

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

i am able to access both project through their url’s but it seem there is now a problem with the images but the css files are loaded.

Error log:

(venv_voicelogging) [marco@mydjangoserver domestic_voicelogging]$ sudo tail -f /var/log/nginx/error.log
2024/09/13 09:07:52 [error] 1497908#1497908: *45 open() "/usr/share/nginx/html/static/images/Login.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /static/images/Login.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/domestic_voicelogging/static/CSS/login.css"
2024/09/13 09:08:00 [error] 1497908#1497908: *48 open() "/usr/share/nginx/html/static/images/Login.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /static/images/Login.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/domestic_voicelogging/static/CSS/login.css"
2024/09/13 09:08:43 [error] 1497908#1497908: *49 open() "/usr/share/nginx/html/static/images/Login.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /static/images/Login.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/domestic_voicelogging/static/CSS/login.css"
2024/09/13 09:13:03 [error] 1497908#1497908: *63 open() "/usr/share/nginx/html/static/images/b1.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /static/images/b1.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/domestic_voicelogging/static/CSS/homeStyle.css"
2024/09/13 09:15:52 [error] 1498024#1498024: *3 open() "/usr/share/nginx/html/static/images/Login.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /static/images/Login.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/domestic_voicelogging/static/CSS/login.css"
2024/09/13 09:24:35 [error] 1498117#1498117: *4 open() "/usr/share/nginx/html/images/Login.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /images/Login.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/domestic_voicelogging/static/CSS/login.css"
2024/09/13 09:27:42 [error] 1498163#1498163: *1 open() "/usr/share/nginx/html/var/www/html/domestic_voicelogging/images/Login.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /var/www/html/domestic_voicelogging/images/Login.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/domestic_voicelogging/static/CSS/login.css"
2024/09/13 09:34:59 [error] 1498163#1498163: *6 open() "/usr/share/nginx/html/var/www/html/domestic_voicelogging/images/Login.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /var/www/html/domestic_voicelogging/images/Login.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/domestic_voicelogging/static/CSS/login.css"
2024/09/13 09:35:02 [error] 1498163#1498163: *4 open() "/usr/share/nginx/html/static/images/b1.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /static/images/b1.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/domestic_voicelogging/static/CSS/homeStyle.css"
2024/09/13 09:41:33 [error] 1498261#1498261: *3 open() "/usr/share/nginx/html/var/www/html/domestic_voicelogging/images/Login.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /var/www/html/domestic_voicelogging/images/Login.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/domestic_voicelogging/static/CSS/login.css"
^C
(venv_voicelogging) [marco@mydjangoserver domestic_voicelogging]$

i have this other nginx config under /nginx/sites-available/domestic_voicelogging:

server {
    listen 80;
    server_name 41.76.110.165;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /domestic_voicelogging/static/ {
         alias /var/www/html/domestic_voicelogging/;
    }

    location / {
         include proxy_params;
         proxy_pass http://unix:/run/gunicorn.sock;
    }
}

i checked the Css background image path and neither of these work after collectstatic:

 background-image: url('/var/www/html/domestic_voicelogging/images/Login.png'); 
background-image: url('/static/images/Login.png');

i think the problem might be here in nginx -T config, the path we are seeing is here:

(venv_voicelogging) [marco@mydjangoserver domestic_voicelogging]$ sudo nginx -T
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# configuration file /etc/nginx/nginx.conf:
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;
    server_names_hash_bucket_size 64;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80;
        listen       [::]:80;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }

  1. Did you try to set the full path for your images?
  2. Do you load static files on your template? {% load static %} ?

@anefta

Yes i do have load static on top:

voiceloggingApp/templates/login.html
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login</title>
    <link rel="stylesheet" href="{% static 'CSS/login.css' %}">
    <link rel="icon" href="{% static 'images/favicon.png' %}" type="image/x-icon">
</head>
<body>

i tried this path but it didn’t work:

 background-image: url('/var/www/html/domestic_voicelogging/images/Login.png'); 

i dont know why my nginx is using this path to find the static files:

ET /wordlist.txt HTTP/1.1", host: "vmcloudhost.interdevsystems.co.za"
2024/09/13 12:46:04 [error] 1499248#1499248: *66 open() "/usr/share/nginx/html/wordlist.txt" failed (2: No such file or directory), client: 185.130.44.86, server: 41.76.110.165, request: "GET /wordlist.txt HTTP/1.1", host: "www.vmcloudhost.interdevsystems.co.za"
2024/09/13 13:08:52 [error] 1499248#1499248: *71 open() "/usr/share/nginx/html/static/images/Login.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request: "GET /static/images/Login.png HTTP/1.1", host: "41.76.110.165", referrer: "http://41.76.110.165/domestic_voicelogging/static/CSS/login.css"
2024/09/13 13:08:57 [error] 1499248#1499248: *74 open() "/usr/share/nginx/html/static/images/Login.png" failed (2: No such file or directory), client: 105.245.236.240, server: 41.76.110.165, request:

i tried commenting out the default from the nginx.config:

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;
    server_names_hash_bucket_size 64;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

#    server {
#        listen       80;
#        listen       [::]:80;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        error_page 404 /404.html;
#        location = /404.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#        location = /50x.html {
#        }
#    }

restarted everything still not showing giving that same error for the path.

When you’re testing this, are you accessing this server by IP address or DNS name?

@KenWhitesell

I am using the IP. I do not have a domain name.

Then assuming a standard implementation (/etc/nginx/nginx.conf and files defined in /etc/nginx/sites-available/ which are then linked to /etc/nginx/sites-enabled/), we would need to see the complete contents of the nginx.conf file and all of the files linked in sites-enabled.

Posting the complete current output of nginx -T would also work.

@KenWhitesell

Here as requested:

[marco@mydjangoserver ~]$ ls /etc/nginx/sites-available
domestic_voicelogging
[marco@mydjangoserver ~]$ ls /etc/nginx/sites-enabled
domestic_voicelogging
[marco@mydjangoserver ~]$ ls -l /etc/nginx/sites-available/
total 4
-rw-r--r--. 1 root root 339 Sep 13 09:40 domestic_voicelogging
[marco@mydjangoserver ~]$ ls -l /etc/nginx/sites-enabled/
total 0
lrwxrwxrwx. 1 root root 48 Jul  3 09:07 domestic_voicelogging -> /etc/nginx/sites-available/domestic_voicelogging
[marco@mydjangoserver ~]$ sudo nginx -T
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# configuration file /etc/nginx/nginx.conf:
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
# include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;
    server_names_hash_bucket_size 64;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

#    server {
#        listen       80;
#        listen       [::]:80;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        error_page 404 /404.html;
#        location = /404.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#        location = /50x.html {
#        }
#    }

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2;
#        listen       [::]:443 ssl http2;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers PROFILE=SYSTEM;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}


# configuration file /etc/nginx/mime.types:

types {
    text/html                                        html htm shtml;
    text/css                                         css;
    text/xml                                         xml;
    image/gif                                        gif;
    image/jpeg                                       jpeg jpg;
    application/javascript                           js;
    application/atom+xml                             atom;
    application/rss+xml                              rss;

    text/mathml                                      mml;
    text/plain                                       txt;
    text/vnd.sun.j2me.app-descriptor                 jad;
    text/vnd.wap.wml                                 wml;
    text/x-component                                 htc;

    image/png                                        png;
    image/svg+xml                                    svg svgz;
    image/tiff                                       tif tiff;
    image/vnd.wap.wbmp                               wbmp;
    image/webp                                       webp;
    image/x-icon                                     ico;
    image/x-jng                                      jng;
    image/x-ms-bmp                                   bmp;

    font/woff                                        woff;
    font/woff2                                       woff2;

    application/java-archive                         jar war ear;
    application/json                                 json;
    application/mac-binhex40                         hqx;
    application/msword                               doc;
    application/pdf                                  pdf;
    application/postscript                           ps eps ai;
    application/rtf                                  rtf;
    application/vnd.apple.mpegurl                    m3u8;
    application/vnd.google-earth.kml+xml             kml;
    application/vnd.google-earth.kmz                 kmz;
    application/vnd.ms-excel                         xls;
    application/vnd.ms-fontobject                    eot;
    application/vnd.ms-powerpoint                    ppt;
    application/vnd.oasis.opendocument.graphics      odg;
    application/vnd.oasis.opendocument.presentation  odp;
    application/vnd.oasis.opendocument.spreadsheet   ods;
    application/vnd.oasis.opendocument.text          odt;
    application/vnd.openxmlformats-officedocument.presentationml.presentation
                                                     pptx;
    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
                                                     xlsx;
    application/vnd.openxmlformats-officedocument.wordprocessingml.document
                                                     docx;
    application/vnd.wap.wmlc                         wmlc;
    application/x-7z-compressed                      7z;
    application/x-cocoa                              cco;
    application/x-java-archive-diff                  jardiff;
    application/x-java-jnlp-file                     jnlp;
    application/x-makeself                           run;
    application/x-perl                               pl pm;
    application/x-pilot                              prc pdb;
    application/x-rar-compressed                     rar;
    application/x-redhat-package-manager             rpm;
    application/x-sea                                sea;
    application/x-shockwave-flash                    swf;
    application/x-stuffit                            sit;
    application/x-tcl                                tcl tk;
    application/x-x509-ca-cert                       der pem crt;
    application/x-xpinstall                          xpi;
    application/xhtml+xml                            xhtml;
    application/xspf+xml                             xspf;
    application/zip                                  zip;

    application/octet-stream                         bin exe dll;
    application/octet-stream                         deb;
    application/octet-stream                         dmg;
    application/octet-stream                         iso img;
    application/octet-stream                         msi msp msm;

    audio/midi                                       mid midi kar;
    audio/mpeg                                       mp3;
    audio/ogg                                        ogg;
    audio/x-m4a                                      m4a;
    audio/x-realaudio                                ra;

    video/3gpp                                       3gpp 3gp;
    video/mp2t                                       ts;
    video/mp4                                        mp4;
    video/mpeg                                       mpeg mpg;
    video/quicktime                                  mov;
    video/webm                                       webm;
    video/x-flv                                      flv;
    video/x-m4v                                      m4v;
    video/x-mng                                      mng;
    video/x-ms-asf                                   asx asf;
    video/x-ms-wmv                                   wmv;
    video/x-msvideo                                  avi;
}

# configuration file /etc/nginx/conf.d/mydjangoserver.conf:
server {
    listen 80;
    server_name 41.76.110.165;

    # Static files for Project 1
    location /domestic_voicelogging/static/ {
        alias /var/www/html/domestic_voicelogging/static/;
    }

    # Static files for Project 2
    location /django_referral/static/ {
        alias /var/www/html/django_referral/static/;
    }

    # Application requests for Project 1
    location /voicelogging/ {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }

    # Application requests for Project 2
    location /djangoprogram/ {
        include proxy_params;
        proxy_pass http://unix:/run/django_referral.sock;
    }

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

# configuration file /etc/nginx/proxy_params:
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

In a “standard” nginx configuration, you would have the line:
include /etc/nginx/sites-enabled/*;
immediately after the line:
include /etc/nginx/conf.d/*.conf;

However, that line is not being shown in your nginx -T output. Therefore, what you’re not seeing in that output are the configuration items from the domestic_voicelogging file. Those settings in that file are not being applied.

The output is showing_ settings from a mydjangoserver.conf file - but those settings more appropriate belong in an appropriate sites-available file and not in the conf.d directory. (And probably should not currently be linked in the sites-enabled directory.)

@KenWhitesell

So do i need create two config files for both projects or should i move the mydjangoserver.conf to the site-available. There is currently a linked config file called domestic_voicelogging with these settings:

server {
    listen 80;
    server_name 41.76.110.165;
location = /favicon.ico { access_log off; log_not_found off; }
    location /domestic_voicelogging/static/ {
         alias /var/www/html/domestic_voicelogging/;
    }
location / {
         include proxy_params;
         proxy_pass http://unix:/run/gunicorn.sock;
    }
}