I am trying to configure my django application on a new server. It works fine unless I try to pass GET parameters. I get the following errors.
uWSGI:
[pid: 21530|app: 0|req: 8/9] 109.68.173.7 () {42 vars in 880 bytes} [Thu Mar 2 17:19:29 2017] GET /install/?token=123&shop=1234&insales_id=124 => generated 0 bytes in 71 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
nginx:
2017/03/02 09:19:29 [error] 21644#0: *1 upstream prematurely closed connection while reading response header from upstream, client: 109.68.173.7, server: 151-248-112-157.xen.vps.regruhosting.ru, request: "GET /install/?token=123&shop=1234&insales_id=124 HTTP/1.1", upstream: "uwsgi://unix:/home/trackpost.sock:", host: "151-248-112-157.xen.vps.regruhosting.ru"
My config files. nginx.conf:
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 120;
client_max_body_size 20M;
uwsgi_read_timeout 86400;
uwsgi_send_timeout 86400;
proxy_buffers 8 32k;
proxy_buffer_size 64k;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name 151-248-112-157.xen.vps.regruhosting.ru;
location = favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/rajansnow/django/trackpost;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/home/trackpost.sock;
}
}
}
app.ini (uwsgi):
[uwsgi]
project = trackpost
username = rajansnow
base = /home/%(username)/django
chdir = %(base)/%(project)
home = %(base)/venv
module = %(project).wsgi:application
plugin = python
master = true
processes = 5
uid = rajansnow
socket = /home/trackpost.sock
chown-socket = rajansnow:nginx
chmod-socket = 666
vacuum = true
touch-reload = /home/rajansnow/django/trackpost/uwsgi.ini
py-autoreload = 3
harakiri = 30
My code is a bit shitty, I know that. But it worked on my previous server, which was Debian based. The current is CentOS based. I've tried everything I found on SO, and no luck. What can I do to fix that?
It's time for mysteries, kids!
The problem mentioned in the question was solved by hard-checking every project file. It turned out that some of them contained unexpected symbols, which used to make Django throw encoding errors, and, as a result, make uwsgi stop.
The mystery part is that the files had been last modified a long time before the problem occured. So how could it happen that they contain extra symbols? Nobody knows.
At least for now, we can say it's solved.