evansd / whitenoise

Radically simplified static file serving for Python web apps
https://whitenoise.readthedocs.io
MIT License
2.55k stars 152 forks source link

nginx with whitenoise #162

Closed geasyheart closed 6 years ago

geasyheart commented 6 years ago

Maybe Django cannot serving static files when debug=False, So i use whitenoise to serving django-rest-framework static files,without nginx evenything work well, but with nginx all static file through nginx,here is my settings:

  1. Django
    
    STATIC_ROOT = os.path.join(BASE_DIR, 'backend_static')
    STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

STATIC_HOST = os.environ.get('ROOT_SERVER_STATIC_HOST', '') STATIC_URL = STATIC_HOST + '/backend_static/'


2. Nginx
#location ^~ /backend_static/ {
#    root /home/workspace/test/django_with_restframework/;
#}
evansd commented 6 years ago

What was the question here?

geasyheart commented 6 years ago

Thanks for your reply! Maybe i didn't make it clear, without nginx,just use django with whitenoise can serving static files well,But the static files cannot find when use nginx reverse proxy django , So i dont understand what's going wrong or that i was wrong.

evansd commented 6 years ago

It sounds like there's a problem with your ngnix configuration rather than an issue with WhiteNoise. You might be better off asking for help on stackoverflow.com