As I prepare to make my page public, I encountered an issue after setting up nginx + gunicorn. The page loads fine, but the CSS is not loading despite no errors being shown in the nginx log file.
Here is a snippet from my nginx.conf
:
server {
listen 8000;
server_name 127.0.0.1;
access_log /<direct_path>/logs/nginx-access.log;
error_log /<direct_path>/logs/nginx-error.log;
location / {
proxy_pass http://127.0.0.1:9000;
}
location /static {
alias /<project path>/chemicalizer;
}
}
My gunicorn configuration (gunicorn.conf.py
) located in the same directory as manage.py
:
bind = "127.0.0.1:9000"
errorlog = '/<direct_path>/logs/gunicorn-error.log'
accesslog = '/<direct_path>/logs/gunicorn-access.log'
loglevel = 'debug'
workers = 4
Information extracted from my project's settings.py
file:
import os, djcelery
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
djcelery.setup_loader()
BROKER_URL = 'amqp://guest:guest@localhost:5672'
SECRET_KEY = censored...
DEBUG = False
ALLOWED_HOSTS = ['0.0.0.0', '127.0.0.1', 'localhost']
INSTALLED_APPS = ( ... )
MIDDLEWARE_CLASSES = ( ... )
ROOT_URLCONF = 'chemicalizer.urls'
TEMPLATES = [ ... ]
I would greatly appreciate any help on this matter. Let me know if there are other files needed for reference.
Update:
Further investigation reveals that while my css
file is being loaded by nginx
, the HTML content sent by gunicorn
seems incomplete. Checking with Chrome's "developer tools," the network tab shows successful loading of the CSS file, but in the sources tab, the CSS file appears empty.
Moreover, the gunicorn-access.log
does not show a GET
command for the css
file. This behavior differs when running a Debug server
. Any insights into why this occurs?