# Basic (newbie) Webrick / ssl config question

**URL:** <https://www.ruby-forum.com/t/basic-newbie-webrick-ssl-config-question/52569>\
**Category:** Rails\
**Created:** [January 16, 2006, 5:13pm UTC](https://www.ruby-forum.com/t/basic-newbie-webrick-ssl-config-question/52569 "2006-01-16T17:13:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![afg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@afg](https://www.ruby-forum.com/u/afg)\
**Post date:** [January 16, 2006, 5:13pm UTC](https://www.ruby-forum.com/t/basic-newbie-webrick-ssl-config-question/52569/1 "2006-01-16T17:13:15Z")

</div>

I have a simple Intranet app I want to make accessible via the  
Internet for remote access by our employees.

I want to use ssl (https) connections and I’ve found enough messages  
to imply Webrick as included in rails can do the job.

The message at  
[http://wrath.rubyonrails.org/pipermail/rails/2005-January/001993.html](http://wrath.rubyonrails.org/pipermail/rails/2005-January/001993.html)  
even appears to tell me exactly how to do it by modifying “server”.

The trouble is my “script/server” is a very simple 3 line script the  
runs “commands/server”.

Where do I find “commands/server”?

And if I only want the production environment to run SSL is that  
easily accomplished?

## Greg

Greg F.  
The Norcross Group  
Forensics for the 21st Century

---

<div class="post-metadata">

**Author:** ![afg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@afg](https://www.ruby-forum.com/u/afg)\
**Post date:** [January 19, 2006, 8:55pm UTC](https://www.ruby-forum.com/t/basic-newbie-webrick-ssl-config-question/52569/2 "2006-01-19T20:55:37Z")

</div>

There might be a better way (if so, somebody say!), but for development  
(winxp) I use two iWEBrick servlets – one https servlet and one http  
servlet (on different ports)

Currently, I use script/server to launch the http servlet and  
script/server.secure (see below) to launch the https servlet.

[script/server.secure]  
#!c:/ruby/bin/ruby  
require File.dirname( **FILE** ) + ‘/…/config/boot’  
#require ‘commands/server’

require ‘webrick’  
require ‘webrick/https’

OPTIONS = {  
:port =\> 3001,  
:ip =\> “127.0.0.1”,  
:environment =\> (ENV[‘RAILS\_ENV’] || “development”).dup,  
:server\_root =\> File.expand\_path(RAILS\_ROOT + “/public/”),

}

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,  
:SSLCertName =\> [ [ “CN”,  
WEBrick::Utils::getservername ] ]  
)  
server.mount(’/’, DispatchServlet, options)  
trap(“INT”) { server.shutdown }  
server.start  
end  
end  
puts “=\> Rails application started on  
http://#{OPTIONS[:ip]}:#{OPTIONS[:port]}”  
puts “=\> Ctrl-c to shutdown”

SSLDispatchServlet.dispatch(OPTIONS)

---

<div class="post-metadata">

**Author:** ![afg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ecc23a/32.png) [@afg](https://www.ruby-forum.com/u/afg)\
**Post date:** [January 20, 2006, 1:30am UTC](https://www.ruby-forum.com/t/basic-newbie-webrick-ssl-config-question/52569/3 "2006-01-20T01:30:39Z")

</div>

Greatly appreciated.

I will try it out tomorrow.

Greg  
On 1/19/06, Zayne K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> #require ‘commands/server’
> 
> class SSLDispatchServlet \< DispatchServlet  
> server.mount(‘/’, DispatchServlet, options)
> 
> > 
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Greg F.  
The Norcross Group  
Forensics for the 21st Century
