# Apache2 + FastCGI + SSL: File upload fails with HTTPS

**URL:** <https://www.ruby-forum.com/t/apache2-fastcgi-ssl-file-upload-fails-with-https/54811>\
**Category:** Rails\
**Created:** [March 14, 2006, 3:30pm UTC](https://www.ruby-forum.com/t/apache2-fastcgi-ssl-file-upload-fails-with-https/54811 "2006-03-14T15:30:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zakmandhro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/3e96dc/32.png) [@zakmandhro](https://www.ruby-forum.com/u/zakmandhro)\
**Post date:** [March 14, 2006, 3:30pm UTC](https://www.ruby-forum.com/t/apache2-fastcgi-ssl-file-upload-fails-with-https/54811/1 "2006-03-14T15:30:47Z")

</div>

All,

I have run into a road block with my RoR project. The app works fine  
without SSL but when I try to upload a file with the site running in  
HTTPS, cgi.rb throws an EOFError:

[13/Mar/2006:23:05:48 :: 22982] Dispatcher failed to catch: bad content  
body (EOFError) /usr/lib/ruby/1.8/cgi.rb:981:in `read_multipartâ?? /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/cgi_ext/raw_post_data_fix.rb:20:in`initialize\_queryâ?? /usr/lib/ruby/1.8/cgi.rb:2270:in `initializeâ?? (eval):16:in`initializeâ?? /usr/lib/ruby/1.8/fcgi.rb:600:in `each_cgiâ?? /usr/lib/ruby/1.8/fcgi.rb:597:in`each\_cgiâ??  
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/fcgi\_handler.rb:52:in  
`process!â?? /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/fcgi_handler.rb:22:in`process!â?? /var/www/familygrove/public/dispatch.fcgi:26  
almost killed by this error

My environment is Ubuntu 6.04, Ruby 1.8.2 and Rails 1.0.0.

Here’s the HEAD from cgi.rb read\_multipart function:

```
def read_multipart(boundary, content_length)
  params = Hash.new([])
  boundary = "--" + boundary
  buf = ""
  bufsize = 10 * 1024

  # start multipart/form-data
  stdinput.binmode if defined? stdinput.binmode
  boundary_size = boundary.size + EOL.size
  content_length -= boundary_size
  status = stdinput.read(boundary_size)
  if nil == status
    raise EOFError, "no content body"
  elsif boundary + EOL != status
    raise EOFError, "bad content body"
  end

```

Are there any known issues with HTTPS upload and the above code block?  
Anyone know of a workaround?

Thanks,

- Zak

---

<div class="post-metadata">

**Author:** ![zakmandhro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/3e96dc/32.png) [@zakmandhro](https://www.ruby-forum.com/u/zakmandhro)\
**Post date:** [March 14, 2006, 3:35pm UTC](https://www.ruby-forum.com/t/apache2-fastcgi-ssl-file-upload-fails-with-https/54811/2 "2006-03-14T15:35:39Z")

</div>

I saw some posts regarding a similar sounding problem with IE file  
uploads. I just wanted to add that this problem occurs in IE 6.x as well  
as Firefox 1.5.

---

<div class="post-metadata">

**Author:** ![zakmandhro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/3e96dc/32.png) [@zakmandhro](https://www.ruby-forum.com/u/zakmandhro)\
**Post date:** [March 14, 2006, 6:04pm UTC](https://www.ruby-forum.com/t/apache2-fastcgi-ssl-file-upload-fails-with-https/54811/3 "2006-03-14T18:04:08Z")

</div>

Thanks for the reply.

Jon L. wrote:

> I assume you meant 5.04.  
> Version 6.04 - Dapper Drake (to be released for production in April)

> Are you using fcgid or fastcgi?  
> fcgid. I got it through apt-get. I added fcgid handler in .htaccess.  
> fcgid seems to work just fine, I can run all use cases, with or without  
> SSL. File upload is the only thing that fails, that’s only with SSL on.

---

<div class="post-metadata">

**Author:** ![zakmandhro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/3e96dc/32.png) [@zakmandhro](https://www.ruby-forum.com/u/zakmandhro)\
**Post date:** [March 14, 2006, 6:32pm UTC](https://www.ruby-forum.com/t/apache2-fastcgi-ssl-file-upload-fails-with-https/54811/4 "2006-03-14T18:32:48Z")

</div>

Hi Zak,

I had a similar problem with fcgid on 5.04. I had to switch back to  
fastcgi because I did not have time to troubleshoot it at that point.  
I too would be interested to see any alternatives/work arounds,  
especially as I would like to go to Dapper too when it is has been  
released.

Regards,  
Jon

–

> **[snowblink](https://snowblink.co.uk/)**
>
> snowblink.co.uk : Homepage

---

<div class="post-metadata">

**Author:** ![zakmandhro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/3e96dc/32.png) [@zakmandhro](https://www.ruby-forum.com/u/zakmandhro)\
**Post date:** [March 14, 2006, 4:54pm UTC](https://www.ruby-forum.com/t/apache2-fastcgi-ssl-file-upload-fails-with-https/54811/5 "2006-03-14T16:54:54Z")

</div>

I assume you meant 5.04.

Are you using fcgid or fastcgi?

## Jon

> **[snowblink](https://snowblink.co.uk/)**
>
> snowblink.co.uk : Homepage

---

<div class="post-metadata">

**Author:** ![zakmandhro](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/3e96dc/32.png) [@zakmandhro](https://www.ruby-forum.com/u/zakmandhro)\
**Post date:** [March 15, 2006, 4:31am UTC](https://www.ruby-forum.com/t/apache2-fastcgi-ssl-file-upload-fails-with-https/54811/6 "2006-03-15T04:31:06Z")

</div>

Jon L. wrote:

> I had a similar problem with fcgid on 5.04. I had to switch back to  
> fastcgi because I did not have time to troubleshoot it at that point.

Thanks Jon. Seems like Dapper has the same issue. I confirmed that the  
problem is with fcgid, and not cgi.rb. I tried SSL with the default CGI  
handler, slowness aside, file upload works just fine.

Are you using FastCGI with Apache 1.x? What is the easiest way to  
install FastCGI with Apache2 without using fcgid, is there an apt  
package? Can you point me in the right direction?

Thanks a bunch!

- Zak
