ubuntu jeos 10.10 spamsnake Bad Gateway baruwa.sock

Discussion in 'HOWTO-Related Questions' started by tuxic, Mar 8, 2011.

  1. tuxic

    tuxic New Member

    Yesterday I followed this guide and got stuck on the following.

    In a browser i keep getting : 502 Bad Gateway

    What i'v read in the forums is that i could have multiple causes. I tried to eliminate them all.

    Now it is down to the fact that uwsgi doesn't correctly read the ini file.

    Here is the uwsgi startup line: (from ps ax)

    Code:
    /usr/bin/uwsgi-python2.6 --master --no-orphans --processes 2 --logdate --chmod-socket=660 --uid www-data --gid www-data --daemonize /var/log/uwsgi/uwsgi-python2.6/baruwa.uwsgi-python2.6.log --pidfile /var/run/uwsgi/uwsgi-python2.6/baruwa/pid --socket /var/run/uwsgi/uwsgi-python2.6/baruwa/socket --ini /etc/uwsgi/uwsgi-python2.6/baruwa.ini
    The baruwa.ini is according to the guide containing:
    Code:
    socket = /var/run/uwsgi/uwsgi-python2.6/baruwa/baruwa.sock
    also the nginx baruwa.conf

    My uwsgi python log shows this:
    Code:
    [uWSGI] getting YAML configuration from /etc/uwsgi/uwsgi-python2.6/baruwa.ini
    Tue Mar  8 14:10:49 2011 - *** Starting uWSGI 0.9.6.6 (64bit) on [Tue Mar  8 14:10:49 2011] ***
    Tue Mar  8 14:10:49 2011 - compiled with version: 4.4.5
    Tue Mar  8 14:10:49 2011 - Python version: 2.6.6 (r266:84292, Sep 15 2010, 16:41:53)
    [GCC 4.4.5]
    Tue Mar  8 14:10:49 2011 - writing pidfile to /var/run/uwsgi/uwsgi-python2.6/baruwa/pid
    Tue Mar  8 14:10:49 2011 - uWSGI running as root, you can use --uid/--gid/--chroot options
    Tue Mar  8 14:10:49 2011 - setgid() to 33
    Tue Mar  8 14:10:49 2011 - setuid() to 33
    Tue Mar  8 14:10:49 2011 - your memory page size is 4096 bytes
    Tue Mar  8 14:10:49 2011 - allocated 648 bytes (0 KB) for 1 request's buffer.
    Tue Mar  8 14:10:49 2011 - binding on UNIX socket: /var/run/uwsgi/uwsgi-python2.6/baruwa/socket
    Tue Mar  8 14:10:49 2011 - your server socket listen backlog is limited to 64 connections
    Tue Mar  8 14:10:49 2011 - initializing hooks...Tue Mar  8 14:10:49 2011 - done.
    Tue Mar  8 14:10:49 2011 - spawned uWSGI master process (pid: 2222)
    Tue Mar  8 14:10:49 2011 - max_ovec = 0
    Tue Mar  8 14:10:49 2011 - spawned uWSGI worker 1 (pid: 2232)
    Tue Mar  8 14:10:49 2011 - spawned uWSGI worker 2 (pid: 2233)
    
    And nginx error.log shows this:
    Code:
    14:16:49 [crit] 2488#0: *1 connect() to unix:///var/run/uwsgi/uwsgi-python2.6/baruwa/baruwa.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.0.145

    Everything is according to the guide with default install of ubuntu server 10.10

    I would greatly appreciate any pointers.

    Thx
     
  2. topdog

    topdog HowtoForge Supporter

    You are specifying the option --socket /var/run/uwsgi/uwsgi-python2.6/baruwa/socket on the command line which overrides the config file
     
  3. tuxic

    tuxic New Member

    Thanks for your reply, are you sure this is default behaviour?

    This is stated in the daemon options:
    Code:
    # Default socket location: /var/run/uwsgi/uwsgi-python2.6/<confname>/socket
    # Tip: you could override '--socket' in configuration file.
    
    Any clue where I can disable the default socket?
     
  4. topdog

    topdog HowtoForge Supporter

    Why the effort, there is nothing wrong with telling nginx there socket is /var/run/uwsgi/uwsgi-python2.6/baruwa/socket
     
  5. Rocky

    Rocky New Member

    Hey,

    Looks like uwsgi is just skipping the socket statement and I'm sure you have /var/run/uwsgi/uwsgi-python2.6/baruwa directory
    created. Must have been some changes with the latest revision.

    Do as Andrew says and just point Nginx over to the socket. You should be fine from there.

     
  6. tuxic

    tuxic New Member

    Thanks for the replies, I tried changing /etc/uwsgi/uwsgi-python2.6/baruwa.ini
    and /etc/nginx/sites-enabled/baruwa.conf

    added: /var/run/uwsgi/uwsgi-python2.6/baruwa/socket

    Now I get a different error:

    Code:
    uWSGI Error
    
    wsgi application not found
    Any other suggestions?
     
  7. Rocky

    Rocky New Member

    Do you have /etc/nginx/uwsgi_params?

    Remember it has to be in this format in your nginx conf file:
    uwsgi_pass unix:////var/run/uwsgi/uwsgi-python2.6/baruwa/socket;
     
    Last edited: Mar 8, 2011
  8. tuxic

    tuxic New Member

    vim /etc/nginx/uwsgi_params
    Code:
    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;
    
    vim /etc/nginx/sites-enabled/baruwa.conf
    Code:
    server {
          listen 80;
          server_name spamsnaketest.com;
          root /usr/share/pyshared/baruwa;
          #main access log
          access_log  /var/log/nginx/access.log;
          #main error log
          error_log /var/log/nginx/error.log;
       location /static {
          root  /usr/share/pyshared/baruwa/static/;
          }
       # static resources
       location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
          {
          expires 30d;
          break;
          }
       location / {
    uwsgi_pass unix:///var/run/uwsgi/uwsgi-python2.6/baruwa/socket;
    include uwsgi_params;
          }
       }
    This is with 3 backslashes according to the guide.

    Any other suggestions, pulling my hair out over this.
     
  9. Rocky

    Rocky New Member

    What version of uwsgi/nginx are you running?

    So your uwsgi baruwa.ini should look like:
    [uwsgi]
    socket = /var/run/uwsgi/uwsgi-python2.6/baruwa/socket
    master = true
    processes = 2
    env = DJANGO_SETTINGS_MODULE=baruwa.settings
    module = django.core.handlers.wsgi:WSGIHandler()

    Your nginx baruwa.conf should look like:
    server {
    listen 80;
    server_name yourhostname;
    root /usr/share/pyshared/baruwa;
    #main access log
    access_log /var/log/nginx/access.log;
    #main error log
    error_log /var/log/nginx/error.log;

    location /static {
    root /usr/share/pyshared/baruwa/static/;
    }
    # static resources

    location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
    {
    expires 30d;
    break;
    }
    location /favicon.ico {
    return 204;
    }

    location / {
    uwsgi_pass unix:///var/run/uwsgi/uwsgi-python2.6/baruwa/socket;
    include uwsgi_params;
    }
    }

    And with these settings, you're still not able to hit the site?

    Make sure and restart your system after making the configs to clear out any cache or so.

    Before you made changes to the conf and ini to /socket, uwsgi was running fine, it was just nginx that needed a pointer. If we can undo the changes, get uwsgi to work, maybe we'll be able to get nginx up by trying a few things with it.
     
    Last edited: Mar 8, 2011
  10. tuxic

    tuxic New Member

    I'm on nginx version: nginx/0.9.5
    and uWSGI 0.9.6.6 (64bit)

    I tried your settings, rebooted and got to the baruwa startup page!!!
    yeah!

    So great, thanks greatly for your help. I can continue now with the guide.

    Many thx
    Tuxic
     
  11. Rocky

    Rocky New Member

    That's great! Must have been a typo somewhere.
     
  12. tuxic

    tuxic New Member

    Just a little follow-up. I finished the rest of the guide without much troubles. The snake is accepting and forwarding emails perfectly.

    There are some minor stuff that aren't very clear and hope to get a short insight.

    - Do i need to run spammassin service at ubuntu start?
    - Quarantaine report from baruwa are sent with address webmaster@localhost, where can I edit this?
    - Some errors in Spamassassin lint:
    Code:
    FuzzyOcr: Cannot find executable for pamthreshold
    FuzzyOcr: Cannot find executable for pamtopnm
    Thx for the great guide and effort of building it.
     
  13. topdog

    topdog HowtoForge Supporter

    - No you do not need to run the spamassassin service, mailscanner uses the spamassassin perl modules.
    - You can use the DEFAULT_FROM_EMAIL option in settings.py to specify the from address you want.
    - Errors are due to the fact that ubuntu
    - The errors are due to the fact that ubuntu/debian netpbm packages seem to have renamed these commands.
     
  14. Rocky

    Rocky New Member

    Make sure the following section in your FuzzyOcr.cf looks like:

    # Include additional scanner/preprocessor commands here:
    #
    focr_bin_helper pnmnorm, pnminvert, ppmtopgm
    #not available in Debian: pamthreshold,pamtopnm
    focr_bin_helper convert, tesseract
     
    Last edited: Mar 11, 2011

Share This Page