django : Serving static files through nginx

后端 未结 5 1806
醉话见心
醉话见心 2020-12-04 09:40

I\'m using apache+mod_wsgi for django.
And all css/js/images are served through nginx.
For some odd reason, when others/friends/colleagues try accessing

5条回答
  •  醉梦人生
    2020-12-04 10:19

    I think using root in location block is incorrect. I use alias and it works fine, even without re-configuring django.

    # django settings.py
    MEDIA_URL = '/static/'
    
    # nginx server config
    server {   
        ...
        location /static {    
            autoindex on;    
            alias /opt/aa/webroot/;    
        }
    }
    

    Hope this makes things simpler.

提交回复
热议问题