How exactly do I server static files with nginx and gunicorn for a Django app? How exactly do I server static files with nginx and gunicorn for a Django app? django django

How exactly do I server static files with nginx and gunicorn for a Django app?


Turns out I fixed my own problem... misunderstood how Nginx worked. :D

server {listen 1234; //port that Nginx listens onserver_name xxx.xx.xx.xx; #the actual IP of the server; it has a public IP addressaccess_log /home/lilo/textImageSite/access.log;error_log /home/lilo/textImageSite/error.log;location /static {    root /home/lilo/textImageSite/imageSite;}location / {    proxy_pass http://127.0.0.1:8888; //the port that Gunicorn uses }}

So in my case, if I have my Gunicorn instance running on port 8888, then going to xxx.xxx.xx.x:8888/textImageSite would load the page, but without any static content. If I access it using xxx.xxx.xx.x:1234, then the page will load the static content (images, css style sheets etc). It's my first time using Gunicorn and Nginx (and first time writing a Django app too) so hopefully this will help someone who's confused :)