# WEBrick 500 error only with https

**URL:** <https://www.ruby-forum.com/t/webrick-500-error-only-with-https/184640>\
**Category:** Rails\
**Created:** [March 5, 2010, 4:57pm UTC](https://www.ruby-forum.com/t/webrick-500-error-only-with-https/184640 "2010-03-05T16:57:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [March 5, 2010, 4:57pm UTC](https://www.ruby-forum.com/t/webrick-500-error-only-with-https/184640/1 "2010-03-05T16:57:47Z")

</div>

I have an application i’m installing on my application server. I’ve  
been  
using WEBrick and for now i’d like to just keep using it working in  
prototype development mode. This works fine on my development machine  
using both http and https, where the host is ‘localhost’ (ports  
3000,3001). It also works fine on the application server http port  
3000.  
The public/index.html also comes up fine using ssl (port 3001), but  
access  
to pages that call a controller fail with following message:

x.x.66.67 - - [04/Mar/2010:17:28:43 MST] “GET /tags HTTP/1.1” 500 948  
[https://x.x.x.x:3001/](https://x.x.x.x:3001/) → /tags

‘tags’ is the name of my model, the request for this error is  
[https://x.x.x.x:3001/tags](https://x.x.x.x:3001/tags)

See below for the full startup of WEBrick, initial index page  
retrieval,  
and then the request for the tags info. Also below is the script i’m  
using  
to start WEBrick. That’s copied from various examples in various  
blogs. It  
seems popular.

I am NOT running two WEBrick’s, just want to run the one copy, all  
ssl, on  
port 3001, or whatever. I do have tomcat running and serving on 443,  
and  
also an instance of apache. I can’t see why they’d be involved though.

Using self generated cert.

I’ve been looking at asset\_host setting, and anything else i can  
google,  
but i can not find anything that tells me what the problem is. I  
suspect  
it must have something to do with redirection and dropping the  
protocol,  
or rather using http rather than https, or maybe it’s dropping the  
port.

Thanks for any clues, signed, confused (Bob).

##############################################################  
rr@sevenof9:~/kbrr$ ./script/server\_ssl -e production  
=\> Booting WEBrick…  
=\> Rails application started on [https://x.x.x.x:3001](https://x.x.x.x:3001)  
=\> Ctrl-C to shutdown  
[2010-03-04 17:27:22] INFO WEBrick 1.3.1  
[2010-03-04 17:27:22] INFO ruby 1.8.6 (2007-09-24) [i486-linux]  
[2010-03-04 17:27:22] INFO  
Certificate:  
Data:  
Version: 1 (0x0)  
Serial Number:  
80:f2:ab:75:5a:02:94:d7  
Signature Algorithm: sha1WithRSAEncryption  
Issuer: C=US,… stuff  
Validity  
Not Before: Mar 3 18:28:16 2010 GMT  
Not After : Feb 29 18:28:16 2020 GMT  
Subject: C=US, …stuff  
Subject Public Key Info:  
Public Key Algorithm: rsaEncryption  
RSA Public Key: (1024 bit)  
Modulus (1024 bit):  
00:ce:61:6d:39:5f:be:ba:86:c8:b1:20:5b:71:b4:  
etc  
f7:c5:bb:69:d4:31:01:08:07  
Exponent: 65537 (0x10001)  
Signature Algorithm: sha1WithRSAEncryption  
aa:f6:e6:71:aa:d6:d1:3e:b7:46:f6:5c:3d:5a:d3:71:a1:c2:  
etc  
27:61  
[2010-03-04 17:27:22] INFO WEBrick::HTTPServer#start: pid=8455  
port=3001  
x.x.66.67 - - [04/Mar/2010:17:28:29 MST] “GET / HTTP/1.1” 200 1341

- → /  
x.x.66.67 - - [04/Mar/2010:17:28:29 MST] “GET  
/javascripts/prototype.js HTTP/1.1” 200 129738  
[https://x.x.x.x:3001/](https://x.x.x.x:3001/) → /javascripts/prototype.js  
x.x.66.67 - - [04/Mar/2010:17:28:30 MST] “GET /javascripts/effects.js  
HTTP/1.1” 200 38675  
[https://x.x.x.x:3001/](https://x.x.x.x:3001/) → /javascripts/effects.js  
x.x.66.67 - - [04/Mar/2010:17:28:43 MST] “GET /tags HTTP/1.1” 500 948  
[https://x.x.x.x:3001/](https://x.x.x.x:3001/) → /tags  
##############################################################

##############################################################  
rr@sevenof9:~/kbrr$ cat script/server\_ssl  
#!/usr/bin/env ruby

require File.dirname( **FILE** ) + ‘/…/config/boot’

require ‘webrick’  
require ‘webrick/https’

puts “=\> Booting WEBrick…”

OPTIONS = {  
:port =\> 3001,  
:ip =\> “x.x.x.x”,  
:environment =\> (ENV[‘RAILS\_ENV’] || “development”).dup,  
:server\_root =\> File.expand\_path(RAILS\_ROOT + “/public/”),  
:pkey =\> OpenSSL::PKey::RSA.new(  
File.open(RAILS\_ROOT +  
“/config/certs/server.key”).read),  
:cert =\> OpenSSL::X509::Certificate.new(  
File.open(RAILS\_ROOT +  
“/config/certs/server.crt”).read),  
:server\_type =\> WEBrick::SimpleServer,  
:charset =\> “UTF-8”,  
:mime\_types =\> WEBrick::HTTPUtils::DefaultMimeTypes,  
:debugger =\> false  
}

ENV[“RAILS\_ENV”] = OPTIONS[:environment]  
RAILS\_ENV.replace(OPTIONS[:environment]) if defined?(RAILS\_ENV)

require RAILS\_ROOT + “/config/environment”  
require ‘webrick\_server’  
OPTIONS[‘working\_directory’] = File.expand\_path(RAILS\_ROOT)

class SSLDispatchServlet \< DispatchServlet  
def self.dispatch(options)  
Socket.do\_not\_reverse\_lookup = true  
server = WEBrick::HTTPServer.new(  
:Port =\> options[:port].to\_i,  
:ServerType =\> options[:server\_type],  
:BindAddress =\> options[:ip],  
:SSLEnable =\> true,  
:SSLVerifyClient =\> OpenSSL::SSL::VERIFY\_NONE,  
:SSLCertificate =\> options[:cert],  
:SSLPrivateKey =\> options[:pkey],  
:SSLCertName =\> [ [ “CN”,  
WEBrick::Utils::getservername ] ]  
)

```
 server.mount('/', DispatchServlet, options)
 trap("INT") { server.shutdown }

 server.start

```

end  
end

puts “=\> Rails application started on  
https://#{OPTIONS[:ip]}:#{OPTIONS[:port]}”  
puts “=\> Ctrl-C to shutdown”

SSLDispatchServlet.dispatch(OPTIONS)  
##############################################################

##############################################################

> From the server, ruby -v and rails -v

ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]  
Rails 2.3.5

rr@sevenof9:~/kbrr$  
uname -a Linux sevenof9 2.6.24-26-server #1 SMP Tue Dec 1 19:19:20 UTC  
2009 i686 GNU/Linux  
##############################################################

---

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [March 5, 2010, 8:36pm UTC](https://www.ruby-forum.com/t/webrick-500-error-only-with-https/184640/2 "2010-03-05T20:36:48Z")

</div>

Never miiiinnnnnddd. Figured it out finally. In the startup script,  
the definition of OPTIONS :environment needs to be changed from  
‘development’ to ‘production’. (My use of -e isn’t actually  
implemented by this script.)
