static files with gunicorn, django and nginx
django, gunicorn, hosts, nginx, static-files
Solution
That seems you have wrong `root` setting.
root /Users/danielrodriguez/workspace/mtt/static;
You should check the requested URL for your css files. Assumimg you have `STATIC_URL = '/static/'` you're browser will probably want to load `/static/css/styles.css` or something like that.
So, the file `./static/css/styles.css` should be found in `root` directory.
Then right `root` should be:
root /Users/danielrodriguez/workspace/mtt;
Of course that's really not good idea to make `root` setting to your project root. So' you may create symlink for `static` and `media` to separate dir outside your project.
Hope that helps.
Problem
I have a django project and want to deploy it using gunicorn and nginx. So far everything works, but when I add subdomains, static files are not served and my page look terrible! If I use localhosts instead, everything works perfect! Here I leave my nginx.conf: ``` server { listen 80 default; client_max_body_size 4G; server_name mytest.dev; keepalive_timeout 5; # path for static files root /Users/danielrodriguez/workspace/mtt/static; location / { # checks for static file, if not found proxy to app try_files $uri @proxy_to_app; } location @proxy_to_app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://localhost:8000; } } ``` I also have this in my hosts file: ``` 127.0.0.1 localhost 127.0.0.1 mytest.dev 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost ``` How can I make nginx to work as it does when I type "localhost" in my browser when I type "mydev.test"? Pretty much all I want to do is serve a bunch of sites within the same physical server using something like virtualhosts in apache. PD: I'm also using OS Lion in case it helps.