Basic (newbie) Webrick / ssl config question

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
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

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)

Greatly appreciated.

I will try it out tomorrow.

Greg
On 1/19/06, Zayne K. [email protected] wrote:

#require ‘commands/server’

class SSLDispatchServlet < DispatchServlet
server.mount(‘/’, DispatchServlet, options)


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


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