Reputation: 115
I have followed a tutorial that I found here and when I am trying to access static files I get a page not found error. Here is the tutorial I was following https://gist.github.com/evildmp/3094281
This is in the error log file for nginx. 2013/07/17 09:55:15 [emerg] 2891#0: "upstream" directive is not allowed here in /etc/nginx/nginx.conf:2
And this is my nginx conf file
# nginx.conf
upstream django {
# connect to this socket
# server unix:///tmp/uwsgi.sock; # for a file socket
server 127.0.0.1:8000; # for a web port socket was 8001
}
server {
# the port your site will be served on
listen 8000;
# the domain name it will serve for
server_name inventory.ien.gatech.edu; # substitute your machine's IP address or FQDN
charset utf-8;
#Max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /Desktop/Projects/Newest/IEN_Inventory/Inventory/templates/media; # your Django project's media files
}
location /static {
alias /Desktop/Projects/Newest/IEN_Inventory/Inventory/templates/media; # your Django project's static files
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params; # or the uwsgi_params you installed manually
}
}
Thanks for any help or advice.
Upvotes: 0
Views: 2539
Reputation: 750
You're missing a http block. Your upstream and server block need to be wrapped by an http block. Your final file would look like this.
EDIT: I've also added in some defaults that are usually supplied with /etc/nginx/nginx.conf
worker_process = 1;
events {
worker_connections 1024;
}
http {
include mime.types.default;
# server_tokens off; # Optional
# sendfile on; # Optional
# keepalive_timeout 100;# Optional
# tcp_nodelay on; # Optional
# nginx.conf
upstream django {
# connect to this socket
# server unix:///tmp/uwsgi.sock; # for a file socket
server 127.0.0.1:8000; # for a web port socket was 8001
}
server {
# the port your site will be served on
listen 8000;
# the domain name it will serve for
server_name server.servername.com; # substitute your machine's IP address or FQDN
charset utf-8;
#Max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /Desktop/Projects/Newest/Inventory/Inventory/templates/media; # your Django project's media files
}
location /static {
alias /Desktop/Projects/Newest/Inventory/Inventory/templates/media; # your Django project's static files
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /etc/nginx/uwsgi_params; # or the uwsgi_params you installed manually
}
}
}
Upvotes: 1