POST causes segfault (502 'upstream prematurely closed connection')

miradev nginx-forum at nginx.us
Tue Aug 4 15:32:12 MSD 2009


I'm stuck trying to find the culprit for an apache segfault.

I have nginx set up on one server for 2 types of site; 'normal' apache sites and wordpress fcgi sites.
The normal apache sites have started to fail on file uploads via the html file form field.

Here is an example config proxying onto apache:

Domain specific MYSITE.conf:

server {
  server_name www.MYSITE.co.uk;
  access_log /var/log/nginx/MYSITE-access.log;
  root /var/www/MYSITE;

  # Default proxy settings
  include /etc/nginx/conf/generic-vhost.conf;

  # Static file serving
  include /etc/nginx/conf/serve-static-files.conf;
}

generic-vhost.conf;

listen PUBLIC_IP:80;
client_max_body_size       25m;
client_body_buffer_size    128k;

location = /internal_server_error.html {
  internal;
  root /var/www/nginx;
}

location = /too_many_connections.html {
  internal;
  root /var/www/nginx;
}

location / {
  proxy_pass         http://127.0.0.1:80/;
  proxy_redirect     default;
  proxy_set_header   Host             $host;
  set_real_ip_from OTHER_PUBLIC_IP;
  real_ip_header X-Real-IP;

  proxy_set_header   X-Real-IP   $proxy_add_x_forwarded_for;
  proxy_set_header   SERVER_PORT $server_port;

  # client_max_body_size       25m;
  # client_body_buffer_size    128k;
  proxy_connect_timeout      90;
  proxy_send_timeout         90;
  proxy_read_timeout         90;
  proxy_buffer_size          4k;
  proxy_buffers              4 32k;
  proxy_busy_buffers_size    64k;
  proxy_temp_file_write_size 64k;
}




serve-static-files.conf;

location ^~ /shared/ {
  alias /var/www/shared/;
  if (!-f $request_filename) {
    proxy_pass http://127.0.0.1:80;
  }
}


# List of extensions that we want to serve using nginx
location ~* ^.+.(jpe?g|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|swf|avi|mp3|tif?f|htc|js)$ {
  proxy_set_header   Host             $host:$server_port;
  proxy_set_header   X-Real-IP        $remote_addr;
  proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
  if (!-f $request_filename) {
    # File not found on disk so let apache deal with the request
    break;
    proxy_pass http://127.0.0.1:80;
  }
}


The nginx access log file shows a 502 response, and Apache doesn't register a hit.

Nginx error log: "upstream prematurely closed connection while reading response header from upstream"]
Apache log: "  child pid 5566 exit signal Segmentation fault (11)"

nginx -V
nginx version: nginx/0.7.59
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-44)
configure arguments: --with-http_realip_module


Any suggestions on where to track down this error?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,4717,4717#msg-4717






More information about the nginx mailing list