django - nginx + gunicorn 502 bad gateway -



django - nginx + gunicorn 502 bad gateway -

i'm trying deploy django project on vps server via nginx , gunicorn, got nginx error '502 bad gateway' when seek open page rollservice-rostov.ru

something wrong nginx configuration, can't figure out is.

/etc/nginx/sites-enabled/rollservice.conf:

upstream rollservice-rostov.ru { server 127.0.0.1:8010 fail_timeout=0; } server { hear 80; server_name www.rollservice-rostov.ru; rewrite ^/(.*) http://rollservice-rostov.ru/$1 permanent; client_max_body_size 4g; access_log /home/django/logs/rollservice/nginx.access.log; error_log /home/django/logs/rollservice/nginx.error.log; location /static/ { alias /home/django/projects/rollservice/static/; } location / { proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://rollservice-rostov.ru; break; } } error_page 500 502 503 504 /500.html; location = /500.html { root /home/django/projects/rollservice/templates/; } }

/etc/supervisor/conf.d/rollservice.conf:

[program:rollservice] command=/home/django/projects/rollservice/run/run.sh directory=/home/django/projects/rollservice user=django autostart=true autorestart=true stderr_logfile=/home/django/logs/rollservice/gunicorn_errors.log stdout_logfile=/home/django/logs/rollservice/gunicorn_access.log

/home/django/projects/rollservice/run/run.sh:

#!/bin/bash name="rollservice" srcdir=rollservice homedir=/home/django projectdir=${homedir}/projects/${name} virtualenv=${homedir}/.envs/${name} sockfile=${homedir}/tmp/${name}.sock user=django group=django num_workers=3 django_settings=rollservice.settings django_wsgi_module=rollservice.wsgi echo "starting $name `whoami`" # activate virtual environment cd $projectdir source ${virtualenv}/bin/activate export django_settings_module=$django_settings export pythonpath=$projectdir:$pythonpath # create run directory if doesn't exist rundir=$(dirname $sockfile) test -d $rundir || mkdir -p $rundir # start django unicorn # programs meant run under supervisor should not daemonize (do not utilize --daemon) exec ${virtualenv}/bin/gunicorn ${django_wsgi_module}:application \ --name $name \ --workers $num_workers \ --user=$user --group=$group \ --bind=127.0.0.1:8010 \ --log-level=debug \ --log-file=$homedir/logs/

although, page opens via

lynx http://127.0.0.1:8010

this lastly error logs:

rollservice-rostov.ru, request: "get / http/1.0", upstream: "http://185.20.226.216:81/", host: "rollservice-rostov.ru" 2014/10/12 23:18:34 [error] 11425#0: *1 connect() failed (111: connection refused) while connecting upstream, client: 185.20.226.216, server: rollservice-rostov.ru, request: "get / http/1.0", upstream: "http://185.20.226.216:81/", host: "rollservice-rostov.ru" 2014/10/12 23:29:02 [error] 11423#0: *3 connect() failed (111: connection refused) while connecting upstream, client: 67.148.203.206, server: rollservice-rostov.ru, request: "get /ccs.php?input http/1.0", upstream: "http://185.20.226.216:81/ccs.php?input", host: "rollservice-rostov.ru" 2014/10/12 23:29:02 [error] 11423#0: *5 connect() failed (111: connection refused) while connecting upstream, client: 67.148.203.206, server: rollservice-rostov.ru, request: "get /modules/404.php http/1.0", upstream: "http://185.20.226.216:81/modules/404.php", host: "rollservice-rostov.ru" 2014/10/12 23:33:10 [error] 11905#0: *1 connect() failed (111: connection refused) while connecting upstream, client: 185.20.226.216, server: rollservice-rostov.ru, request: "get / http/1.0", upstream: "http://185.20.226.216:81/", host: "rollservice-rostov.ru" 2014/10/12 23:33:12 [error] 11905#0: *3 connect() failed (111: connection refused) while connecting upstream, client: 141.105.68.10, server: rollservice-rostov.ru, request: "get /ccs.php?input http/1.0", upstream: "http://185.20.226.216:81/ccs.php?input", host: "rollservice-rostov.ru" [vps]rollservice> sudo tail /var/log/nginx/error.log 2014/10/12 23:13:27 [error] 11106#0: *1 connect() failed (111: connection refused) while connecting upstream, client: 185.20.226.216, server: rollservice-rostov.ru, request: "get / http/1.0", upstream: "http://185.20.226.216:81/", host: "rollservice-rostov.ru" 2014/10/12 23:16:46 [error] 11295#0: *1 connect() failed (111: connection refused) while connecting upstream, client: 185.20.226.216, server: rollservice-rostov.ru, request: "get / http/1.0", upstream: "http://185.20.226.216:81/", host: "rollservice-rostov.ru" 2014/10/12 23:18:34 [error] 11425#0: *1 connect() failed (111: connection refused) while connecting upstream, client: 185.20.226.216, server: rollservice-rostov.ru, request: "get / http/1.0", upstream: "http://185.20.226.216:81/", host: "rollservice-rostov.ru" 2014/10/12 23:29:02 [error] 11423#0: *3 connect() failed (111: connection refused) while connecting upstream, client: 67.148.203.206, server: rollservice-rostov.ru, request: "get /ccs.php?input http/1.0", upstream: "http://185.20.226.216:81/ccs.php?input", host: "rollservice-rostov.ru" 2014/10/12 23:29:02 [error] 11423#0: *5 connect() failed (111: connection refused) while connecting upstream, client: 67.148.203.206, server: rollservice-rostov.ru, request: "get /modules/404.php http/1.0", upstream: "http://185.20.226.216:81/modules/404.php", host: "rollservice-rostov.ru" 2014/10/12 23:33:10 [error] 11905#0: *1 connect() failed (111: connection refused) while connecting upstream, client: 185.20.226.216, server: rollservice-rostov.ru, request: "get / http/1.0", upstream: "http://185.20.226.216:81/", host: "rollservice-rostov.ru" 2014/10/12 23:33:12 [error] 11905#0: *3 connect() failed (111: connection refused) while connecting upstream, client: 141.105.68.10, server: rollservice-rostov.ru, request: "get /ccs.php?input http/1.0", upstream: "http://185.20.226.216:81/ccs.php?input", host: "rollservice-rostov.ru" 2014/10/12 23:35:22 [error] 11905#0: *5 connect() failed (111: connection refused) while connecting upstream, client: 93.72.37.129, server: rollservice-rostov.ru, request: "get / http/1.1", upstream: "http://185.20.226.216:81/", host: "185.20.226.216" 2014/10/12 23:35:22 [error] 11905#0: *7 connect() failed (111: connection refused) while connecting upstream, client: 93.72.37.129, server: rollservice-rostov.ru, request: "get /favicon.ico http/1.1", upstream: "http://185.20.226.216:81/favicon.ico", host: "185.20.226.216" 2014/10/12 23:35:22 [error] 11905#0: *9 connect() failed (111: connection refused) while connecting upstream, client: 93.72.37.129, server: rollservice-rostov.ru, request: "get /favicon.ico http/1.1", upstream: "http://185.20.226.216:81/favicon.ico", host: "185.20.226.216"

the problem looks proxy_pass passing fqdn due naming of stream.

if (!-f $request_filename) { proxy_pass http://rollservice-rostov.ru; break; }

it passing straight that. alter name of upstream , should okay.

joe

django nginx gunicorn

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -