Re: nginx fastcgi continued..

Matt Bartolome
2009-06-18T15:49:17+00:00

Hi Matt,
Your issue seems oddly familiar to me but I forget how I fixed it. I'm
running nginx-0.7.34 built from source and django trunk Rev: 10558. I would
try doing a source build of the current release of nginx which is 0.7.60
first to see if that fixes it. The fastcgi-params are also picky so check
those too.

Here's how I start mine up.

su -m -c 'python /var/django/projects/gis/manage.py runfcgi
        include fastcgi-params;
        fastcgi-pass-header Authorization;
        fastcgi-intercept-errors off;
    }


and my fastcgi-params are:

fastcgi-param  PATH-INFO          $fastcgi-script-name;
fastcgi-param  QUERY-STRING       $query-string;
fastcgi-param  REQUEST-METHOD     $request-method;
fastcgi-param  CONTENT-TYPE       $content-type;
fastcgi-param  CONTENT-LENGTH     $content-length;

fastcgi-param  REQUEST-URI        $request-uri;
fastcgi-param  DOCUMENT-URI       $document-uri;
fastcgi-param  DOCUMENT-ROOT      $document-root;
fastcgi-param  SERVER-PROTOCOL    $server-protocol;

fastcgi-param  GATEWAY-INTERFACE  CGI/1.1;
fastcgi-param  SERVER-SOFTWARE    nginx/$nginx-version;

fastcgi-param  REMOTE-ADDR        $remote-addr;
fastcgi-param  REMOTE-PORT        $remote-port;
fastcgi-param  SERVER-ADDR        $server-addr;
fastcgi-param  SERVER-PORT        $server-port;
fastcgi-param  SERVER-NAME        $server-name;

# PHP only, required if PHP was built with >
> I'm on ubuntu hardy heron, 2.6.24-19-server 64 bit
> nginx/0.5.33
> django 1.0.2
> Python 2.5.2
> mysql 5.0.51a-3ubuntu5.4
>
> Here's how I installed everything from the beginning
>
> http://pastie.org/515408
>
> Here's how I restart my django app
>
> #!/bin/sh
> if [ -f /var/www/django/conf/pid/$1.pid ]; then
>        echo stopping $1 site
>  kill `cat /var/www/django/conf/pid/$1.pid`
> else
>        echo $1 was not running
> fi
> /usr/bin/python /var/www/django//$1/manage.py runfcgi method=prefork
> minspare=1 maxspare=1 socket=/var/www/django/conf/sockets/$1.sock
> pidfile=/var/www/django/conf/pid/$1.pid
> chmod 777 /var/www/django/conf/sockets/$1.sock
>
> Here's the server directive in the /etc/nginx/sites-available/default file
> server
> {
>    listen   80;
>    server-name $1.com;
>    access-log /var/www/django/log/access.log;
>    error-log /var/www/django/log/error.log error;
>    location /
>    {
>        fastcgi-pass unix:/var/www/django/conf/sockets/$1.sock;
>        fastcgi-param SERVER-NAME $server-name;
>        fastcgi-param SERVER-PORT $server-port;
>        fastcgi-param SERVER-PROTOCOL $server-protocol;
>        fastcgi-param PATH-INFO $fastcgi-script-name;
>        fastcgi-param REQUEST-METHOD $request-method;
>        fastcgi-param QUERY-STRING $query-string;
>        fastcgi-param CONTENT-TYPE $content-type;
>        fastcgi-param CONTENT-LENGTH $content-length;
>        fastcgi-pass-header Authorization;
>        fastcgi-intercept-errors off;
>    }
> }
>
> Here's the /etc/nginx/nginx.conf
> user username groupname;
> worker-processes  6;
> error-log  /var/log/nginx/error.log;
> pid        /var/run/nginx.pid;
> events {
>    worker-connections  1024;
> }
> http {
>    include       /etc/nginx/mime.types;
>    default-type  application/octet-stream;
>    access-log  /var/log/nginx/access.log;
>    sendfile        on;
>    #tcp-nopush     on;
>    #keepalive-timeout  0;
>    keepalive-timeout  65;
>    tcp-nodelay        on;
>    gzip  on;
>    include /etc/nginx/sites-enabled/*;
> }
>
> Every now and then the web site returns a 502 bad gateway error. It's
> a very small site with hardly any traffic, so  resources are not a
> problem.  It usually happens immediately after I restart the site with
> the script above, I'm wondering if the restarting is a problem.
>
> Here's what nginx says about it, running in error mode
>
> 2009/06/17 17:09:22 [error] 17715#0: *10888 connect() to
> unix:/var/www/django/conf/sockets/$1.sock failed (111: Connection
> refused) while connecting to upstream, client: 82.15.29.187, server:
> servername, URL:
> "/news/2009/jun/09/summer-fund-now-open-applications-continuing-stude/",
> upstream: "fastcgi://unix:/var/www/django/conf/sockets/$1.sock:",
> host: "servername", referrer: "http://somewebsite.com/"
>
> I've switched file caching on now in django, so I'm not getting any
> errors any more, but I need to understand what is causing those
> errors, for my own sanity if nothing else
>
> I can get any log information if needed, and perform any tests.  I
> think I've got something setup slightly wrong, but I have no idea what
> it is.
>
> If anyone can shed any light on the topic I'd be most grateful.
>
> V
>
> >
>

------------------------------------------

Loading


$ This page is proudly powered by www.pubbs.net, you can see more at django archive | Partners: ListWare Global Manufacturers