I can serve my django app running uwsgi --socket lhhs/lhhs.sock --module lhhs/lhhs.wsgi --chmod-socket=664
And the django app runs quick and running python manage.py test shows it is fine.
But uisng nginx and uwsgi-emperor I get
upstream prematurely closed connection while reading response header from upstream, client: 74.45.12.120, server: lhhs.oh-joy, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///var/www/webapps/lhhs/lhhs/lhhs.sock:", host: "lhhs.oh-joy"
Here is my .ini file:
uid = www-data
chdir=/var/www/webapps/lhhs/lhhs
home=/var/www/webapps/lhhs/env
virtualenv=/var/www/webapps/lhhs/env
module=lhhs.wsgi:application
master=True
pidfile=/tmp/project-master.pid
vacuum=True
max-requests=5000
daemonize=/var/www/webapps/lhhs/log/lhhs-uwsgi.log
socket=/var/www/webapps/lhhs/lhhs/lhhs.sock
chmod-socket = 664
Here is my nginx config:
upstream django {
server unix:///var/www/webapps/lhhs/lhhs/lhhs.sock; # for a file socket
#server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
server {
listen 443 ssl;
server_name lhhs.oh-joy;
charset utf-8;
ssl_certificate /etc/letsencrypt/live/lhhs.oh-joy/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/lhhs.oh-joy/privkey.pem; # managed by Certbot
location /static {
alias /var/www/webapps/lhhs/lhhs/static;
}
location /media {
alias /var/www/webapps/lhhs/lhhs/media;
}
location /favicon.ico {
alias /var/www/webapps/lhhs/lhhs/static/images/favicon.ico;
}
location / {
include /etc/nginx/uwsgi_params;
uwsgi_pass django;
}
}
server {
if ($host = lhhs.oh-joy) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name lhhs.oh-joy;
return 404; # managed by Certbot
}
I see what is going on, but I'm snot sure how to fix it. The uwsgi runs globally when using emperor, but even though I have home and virtualenv set it doesn't recognize my environment.
I can serve my django app running uwsgi --socket lhhs/lhhs.sock --module lhhs/lhhs.wsgi --chmod-socket=664
And the django app runs quick and running python manage.py test shows it is fine.
But uisng nginx and uwsgi-emperor I get
upstream prematurely closed connection while reading response header from upstream, client: 74.45.12.120, server: lhhs.oh-joy., request: "GET / HTTP/1.1", upstream: "uwsgi://unix:///var/www/webapps/lhhs/lhhs/lhhs.sock:", host: "lhhs.oh-joy."
Here is my .ini file:
uid = www-data
chdir=/var/www/webapps/lhhs/lhhs
home=/var/www/webapps/lhhs/env
virtualenv=/var/www/webapps/lhhs/env
module=lhhs.wsgi:application
master=True
pidfile=/tmp/project-master.pid
vacuum=True
max-requests=5000
daemonize=/var/www/webapps/lhhs/log/lhhs-uwsgi.log
socket=/var/www/webapps/lhhs/lhhs/lhhs.sock
chmod-socket = 664
Here is my nginx config:
upstream django {
server unix:///var/www/webapps/lhhs/lhhs/lhhs.sock; # for a file socket
#server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
server {
listen 443 ssl;
server_name lhhs.oh-joy.;
charset utf-8;
ssl_certificate /etc/letsencrypt/live/lhhs.oh-joy./fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/lhhs.oh-joy./privkey.pem; # managed by Certbot
location /static {
alias /var/www/webapps/lhhs/lhhs/static;
}
location /media {
alias /var/www/webapps/lhhs/lhhs/media;
}
location /favicon.ico {
alias /var/www/webapps/lhhs/lhhs/static/images/favicon.ico;
}
location / {
include /etc/nginx/uwsgi_params;
uwsgi_pass django;
}
}
server {
if ($host = lhhs.oh-joy.) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name lhhs.oh-joy.;
return 404; # managed by Certbot
}
I see what is going on, but I'm snot sure how to fix it. The uwsgi runs globally when using emperor, but even though I have home and virtualenv set it doesn't recognize my environment.
Share Improve this question edited Mar 19 at 20:35 bradrice asked Mar 19 at 15:24 bradricebradrice 1,7753 gold badges25 silver badges50 bronze badges1 Answer
Reset to default 1I not pretty sure that your problem is environment rather than a typo that you made in the following code... no need for these // double slashes in server attribute.
upstream django {
server unix:/var/www/webapps/lhhs/lhhs/lhhs.sock; # for a file socket
#server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}