Skip to content

Instantly share code, notes, and snippets.

@ruslanosipov
Created June 19, 2013 15:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruslanosipov/5815349 to your computer and use it in GitHub Desktop.
Save ruslanosipov/5815349 to your computer and use it in GitHub Desktop.
Rails server over SSL, do "bundle exec ruby scripts/rails_secure.rb server"
#!/usr/bin/env ruby
require 'rubygems' # if ruby 1.8.7
require 'rails/commands/server'
require 'rack'
require 'webrick'
require 'webrick/https'
module Rails
class Server < ::Rack::Server
def default_options
super.merge({
:Port => 3001,
:environment => (ENV['RAILS_ENV'] || "development").dup,
:daemonize => false,
:debugger => false,
:config => File.expand_path("config.ru"),
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
# Optional: load a certificate "custom.cert.key"
# :SSLPrivateKey => OpenSSL::PKey::RSA.new(
# File.open("config/cert/ss/custom.cert.key").read),
# :SSLCertificate => OpenSSL::X509::Certificate.new(
# File.open("config/cert/ss/custom.cert.crt").read),
:SSLCertName => [["CN", WEBrick::Utils::getservername]],
})
end
end
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment