Connection reset by server

I am trying to upload a 4mb file to my Drupal server…

Here is my nginx.conf:

user www-data;
worker_processes 2;

events {

worker_connections  1024;

}

http {

   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 SCRIPT_FILENAME $document_root$fastcgi_script_name;
   fastcgi_param SCRIPT_NAME $fastcgi_script_name;
   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 $http_host;
   #fastcgi_param SERVER_NAME $server_name;
   # PHP only, required if PHP was built with

–enable-force-cgi-redirect
#fastcgi_param REDIRECT_STATUS 200;
fastcgi_ignore_client_abort on;
fastcgi_buffers 32 8k;

## MIME types
   include       mime.types;
   default_type  application/octet-stream;

## Size Limits
   client_body_buffer_size   1k;
   client_header_buffer_size 1k;
   # keep default client_max_body_size
   client_max_body_size      10m;
   large_client_header_buffers 1 1k;

## Timeouts
   client_body_timeout   5;
   client_header_timeout 5;
   keepalive_timeout     20;
   send_timeout          5;

## General Options
   ignore_invalid_headers   on;
   limit_zone gulag $binary_remote_addr 1m;
   recursive_error_pages    on;
   sendfile                 on;
   server_name_in_redirect off;
   server_tokens           off;

## TCP options
   tcp_nodelay on;
   #tcp_nopush  on;

## Compression
   gzip              on;
   gzip_buffers      16 8k;
   gzip_comp_level   9;
   gzip_http_version 1.0;
   gzip_min_length   0;
   gzip_types        text/plain text/html text/css image/x-icon

image/png;
gzip_vary on;

   server {

       ## Serve an empty 1x1 gif _OR_ an error 204 (No Content) for

favicon.ico
location = /favicon.ico {
#empty_gif;
return 204;
}

}

include /usr/local/nginx/sites-enabled/*;

}

– Adam

“Courage is not the absence of fear, but rather the judgment that
something
else is more important than fear.” — Ambrose Redmoon

Upon further inspection, I am getting a 405 when POST is submitting to a
Drupal module and Clean URL is enabled. It works fine without Clean
URLs.
It is an AJAX form that submits to /upload/js (clean) OR
index.php?q=upload/js (dirty).

My rewrite is ^/(.*)$ index.php?q=$1

I could really use some help with this!

– Adam

“Courage is not the absence of fear, but rather the judgment that
something
else is more important than fear.” — Ambrose Redmoon

On Saturday 23 August 2008, Adam Setzler wrote:

Upon further inspection, I am getting a 405 when POST is submitting to a
Drupal module and Clean URL is enabled. It works fine without Clean URLs.
It is an AJAX form that submits to /upload/js (clean) OR
index.php?q=upload/js (dirty).

My rewrite is ^/(.*)$ index.php?q=$1

add a slash before index.php

rewrite ^/(.*)$ /index.php?q=$1

I apologize for being lazy… Here is my actual rewrite from the
sites-available dir, which includes that preceding slash…

location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
}

– Adam

“Courage is not the absence of fear, but rather the judgment that
something
else is more important than fear.” — Ambrose Redmoon

no, that’s a required HTML enctype in the tag to be able to
submit file uploads. it’d probably help if you included the version of
nginx you’re using.

i host a drupal site currently and there’s been no complaints (not
sure if they’re using file uploads though) using nginx 0.7.8 (i need
to upgrade too)

I just found this in the Drupal upload module…

$form[’#attributes’][‘enctype’] = ‘multipart/form-data’;

Does this mean I need to have the Nginx Upload mod installed?

– Adam

“Courage is not the absence of fear, but rather the judgment that
something
else is more important than fear.” — Ambrose Redmoon

I figured it out… Here’s what was happening.

I was setting the expiration of certain file extensions to 30 days with:

location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ {
access_log off;
expires 30d;
}

So, when the AJAX function was posting to upload/js, Nginx thought it
was a
static file, so Nginx threw a 405 Not Allowed. Why? Because I failed
to
escape the “.” (any character) before js, so upload/js was the same as
upload.js.

Correct regexp:

location ~* ^.+**.(jpg|jpeg|gif|css|png|js|ico)$ {
access_log off;
expires 30d;
}

Thanks for the insight, everyone.

– Adam

“Courage is not the absence of fear, but rather the judgment that
something
else is more important than fear.” — Ambrose Redmoon

On second thought… Shame on the Drupal developers for using a common
file
extension in the path!

– Adam

“Courage is not the absence of fear, but rather the judgment that
something
else is more important than fear.” — Ambrose Redmoon

On Saturday 23 August 2008, Adam Setzler wrote:

static file, so Nginx threw a 405 Not Allowed. Why? Because I failed to
escape the “.” (any character) before js, so upload/js was the same as
upload.js.

Correct regexp:

location ~* ^.+**.(jpg|jpeg|gif|css|png|js|ico)$ {
access_log off;
expires 30d;
}

does not look like correct one
but this one is:

location ~* .(jpg|jpeg|gif|css|png|js|ico)$