Created
February 25, 2013 10:07
-
-
Save mindscratch/5028880 to your computer and use it in GitHub Desktop.
Start WEBrick with SSL enabled. ## Usage bundle exec ruby script/secure_rails s -e <environment> -p <port>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env jruby | |
%W{rails/command/server rack webrick webrick/https}.each { |lib| require lib } | |
ENV['HTTPS'] = 'on' | |
module Rails | |
class Server < ::Rack::Server | |
def default_options | |
super.merge({ | |
:environment => (ENV['RAILS_ENV'] || 'development').dup, | |
:daemonize => false, | |
:pid => File.expand_path(File.join('tmp', 'pids', 'server.pid')), | |
:config => File.expand_path('config.ru'), | |
:SSLEnable => true, | |
:SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER, | |
:SSLPrivateKey => OpenSSL::PKey::RSA.new(File.read('/path/to/id_rsa'), 'password'), | |
:SSLCertificate => OpenSSL:X509::Certificate.new(File.read('/path/to/id_rsa.pub')), | |
:SSLCACertificateFile => '/path/to/ca.crt', | |
: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