I have a Django+nginx+uwsgi stack set up on my Production server and I'm trying to get it to run on port 80. To test my Django app, I tried manage.py runserver 0.0.0.0:80 but it gave me a permissions issue. I attempted to sudo the command but django is only installed on my virtualenv so it ran into issues. I can hit my server on port 80 through a browser and it has the default nginx splash page. Here are my config files:
nginx.conf
# mysite_nginx.conf
# the upstream component nginx needs to connect to
upstream django {
server 127.0.0.1:8000; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on and the domain name it will serve for
listen 8000;
server_name ip-address-here; # substitute your machine's IP address or FQD
root /home/user1;
access_log /home/user1/logs/access.log;
error_log /home/user1/logs/error.log;
charset utf-8;
gzip on;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media/ {
alias /home/user1/Project/static/img/; # your Django project's media files - ame$
}
location /static/ {
alias /home/user1/Project/static/; # your Django project's static files - amend a$
}
location /img/ {
autoindex on;
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass 127.0.0.1:8889;
include uwsgi_params; # the uwsgi_params file you installed
}
}
uwsgi.ini
[uwsgi]
# variables
projectname = Project
projectdomain = project.com
base = /home/user1
# config
master = true
protocol = uwsgi
env = DJANGO_SETTINGS_MODULE=%(projectname).settings
pythonpath = %(base)/%(projectname)
module = %(projectname).wsgi:application
socket = 127.0.0.1:8889
logto = %(base)/logs/uwsgi.log
#below line runs it as a daemon in background
daemonize = /home/user1/logs/project_uwsgi.log
Also, when it comes to running a stack like this, what kind of users should I have set up? Ie. What user should I run nginx as? What user should I set up my project under? Currently, I have my project set up under the /home/user1 directory, and I'm running nginx as user1. I also use user1 to ssh into my machine. I have disabled the root account for security purposes, but user1 has sudo privileges.