gunicorn 19.0 broken under arch/nginx #785

Closed
adontz opened this Issue Jun 13, 2014 · 4 comments

Projects

None yet

3 participants

@adontz
adontz commented Jun 13, 2014

I have nginx (from pacman) under archlinux with the following config

proxy_temp_path                    /var/tmp/nginx/temp;
proxy_cache_path                   /var/tmp/nginx/cache keys_zone=default_path:100m;
proxy_connect_timeout              5;
proxy_read_timeout                 5;
proxy_redirect                     off;
proxy_set_header                   Host $http_host;
proxy_set_header                   X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header                   X-Real-IP $remote_addr;
proxy_set_header                   X-Scheme $scheme;
proxy_set_header                   REMOTE_ADDR $remote_addr;
proxy_http_version                 1.1;
proxy_pass_header                  Server;
....
upstream gunicorn_xyz_server {
    server unix:/var/run/gunicorn-xyz.sock max_fails=1 fail_timeout=10 weight=1;
}

location ^~/pages/ {
    limit_except               GET HEAD { deny all; }
    expires 24h;

    proxy_pass                 http://gunicorn_xyz_server;
    proxy_cache                default_path;
    proxy_cache_key            "$server_name$request_uri";
    proxy_cache_valid          200 1d;
    proxy_cache_use_stale      error timeout updating http_500;
}

gunicorn (from pip) is run as service with the following config

[Unit]
Description=gunicorn xyz daemon

[Service]
Type=forking
PIDFile=/var/run/gunicorn-xyz.pid
User=root
WorkingDirectory=/usr/bin
ExecStart=/usr/bin/gunicorn --config /data/django/projects/xyz/gunicorn.py wsgi:application
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID

[Install]
WantedBy=multi-user.target

After upgrading to 19.0 I get the following error

2014-06-13 09:37:58 [3163] [ERROR] Error handling request
Traceback (most recent call last):
  File "/usr/lib/python3.4/site-packages/gunicorn/workers/sync.py", line 93, in handle
    self.handle_request(listener, req, client, addr)
  File "/usr/lib/python3.4/site-packages/gunicorn/workers/sync.py", line 125, in handle_request
    listener.getsockname(), self.cfg)
  File "/usr/lib/python3.4/site-packages/gunicorn/http/wsgi.py", line 163, in create
    environ['REMOTE_ADDR'] = client[0]
IndexError: index out of range

simply downgrading to 18.0 helps.

If that matters gunicorn serves django web site.

@benoitc
Owner
benoitc commented Jun 13, 2014

what is the gunicorn configuration? Can you paste it?

@adontz
adontz commented Jun 13, 2014

sure, here is my /data/django/projects/xyz/gunicorn.py

import os;

chdir = '/data/django/projects/xyz/';
raw_env = [ 'DJANGO_SETTINGS_MODULE=settings' ];

accesslog = '/var/log/gunicorn-xyz-access.log';
errorlog  = '/var/log/gunicorn-xyz-error.log';
pidfile   = '/var/run/gunicorn-xyz.pid';
loglevel  = 'debug';

bind = 'unix:/var/run/gunicorn-xyz.sock'
backlog = 16;

limit_request_line       = 1024 * 1024;
limit_request_field_size = 1024 * 1024;
limit_request_fields     =  256;

workers = 2;
max_requests = 16;

timeout = 30;
keepalive = 30;
graceful_timeout = 30;

daemon = True;
@benoitc benoitc closed this in fd5c2e9 Jun 13, 2014
@benoitc
Owner
benoitc commented Jun 13, 2014

fixed thanks!

@hnykda
hnykda commented Jul 9, 2014

Confirm - problem fixed.

@alex-kaufman alex-kaufman referenced this issue in KeepSafe/aiohttp Dec 3, 2015
Closed

Index out of range in create_wsgi_environ #653

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment