Hi there,
During deployment of Django (Gunicorn+Nginx) I have encountered the following issue:
- Site loads correctly, and debug default page comes on. The terminal annouces the first two errors:
(django_env) user@mysite.com:$ Not Found: /error/403.html
Not Found: /favicon.ico
-
When navigating to mysite.com/admin none of the static files are loading, and multiple “Not Found: /error/403.html” are returned on the terminal.
-
I have checked nginx error log, finding no server 403 errors (just a warning relating ssl stapling):
2021/08/28 00:08:00 [warn] 4549#4549: "ssl_stapling" ignored, issuer certificate not found...
- I have checked the permissions on my static folder (/home/user/myproject/static) and are set to 755:
This is what my settings.py static section looks like:
STATIC_URL = '/static/'
STATIC_ROOT = "/home/user/myproject/static"
This is what my nginx myproject.conf file looks like
server {
listen xxxxxxxxxx:443 ssl;
server_name site.com;
ssl_certificate /usr/local/xxxxxx.crt;
ssl_certificate_key /usr/local/xxxxx.key;
#access_log /var/log/ngin/xxxxxxxxx.log main;
location /static/ {
alias /home/user/myproject/static;
}
location / {
proxy_pass http://xxxxxxxx:8000/;
}
}
User set in nginx.conf is ‘nginx’ and the rest of relevant configurations go as follow:
# Server globals
user nginx;
################
# Error pages
error_page 403 /error/403.html;
error_page 404 /error/404.html;
error_page 502 503 504 /error/50x.html;
###############
# Wildcard include
include /etc/nginx/sites-enabled/myproject;
I am certain I might have missed several things here (maybe I should pay attention to the whole permission hierarchy, setting permissions elsewhere, adequately configure nginx…), forgive my limited experience.
Thank you in advance for your help!