I would opt for Nginx + uwsgi, what I usually do is launch uwsgi using Supervisor for auto-start, restart, etc.
I leave the config of my web (simplified, since I removed the SSL configuration to simplify)
NGINX config
upstream alanwagner {
server unix:/home/alan/deploy/alanwagner/alanwagner.sock;
}
server {
server_name www.alanwagner.es;
listen 80;
# Esto es para optimizar tus estáticos
location /static {
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
#gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
expires 30d;
add_header Pragma public;
add_header Cache-Control "public";
alias /home/alan/webs/alanwagner_2018/personal_site/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
error_log /home/alan/deploy/alanwagner/tmp/logs/error.log warn;
location / {
# return 503;
# auth_basic "Restricted";
# auth_basic_user_file /etc/nginx/.htpasswd;
uwsgi_pass alanwagner;
include /home/alan/deploy/alanwagner/uwsgi_params; # the uwsgi_params file you installed
uwsgi_read_timeout 600s;
uwsgi_send_timeout 600s;
}
UWSGI PARAMS
uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;
uwsgi.ini
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /home/alan/webs/alanwagner_2018/personal_site
# Django's wsgi file
module = personal_site.wsgi
# the virtualenv (full path)
#home = /home/alan/webs/refundair
home = /home/alan/venvs/alanwagner
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 2
# the socket (use the full path to be safe
socket = /home/alan/deploy/alanwagner/alanwagner.sock
# ... with appropriate permissions - may be needed
chmod-socket = 777
#uid = www-data
#gid = www-data
# clear environment on exit
vacuum = true
Supervisor file
[program:uwsgi_alanwagner]
user = alan
command = /home/alan/venvs/alanwagner/bin/uwsgi --ini /home/alan/deploy/alanwagner/uwsgi.ini
autostart=true
autorestart=true
stderr_logfile = /home/alan/deploy/alanwagner/logs/uwsgi/err.log
stdout_logfile = /home/alan/deploy/alanwagner/logs/uwsgi/out.log
stopsignal=INT