我使用以下环境:
Server: Webrick
Rails: 3.2.6
Ruby: 1.9.3p555
我在/ script / rails中添加了以下代码:
require 'rails/commands/server'
require 'rack'
require 'webrick'
require 'webrick/https'
if ENV['SSL'] == "true"
module Rails
class Server < ::Rack::Server
def default_options
super.merge({
:Port => 443,
:environment => (ENV['RAILS_ENV'] || "production").dup,
:daemonize => false,
:debugger => false,
:pid => File.expand_path("tmp/pids/server.pid"),
:config => File.expand_path("config.ru"),
:SSLEnable => true,
:SSLVerifyClient => OpenSSL::SSL::VERIFY_NONE,
:SSLPrivateKey => OpenSSL::PKey::RSA.new(
File.open("certs/project.key").read),
:SSLCertificate => OpenSSL::X509::Certificate.new(
File.open("certs/project.crt").read),
:SSLCertName => [["CN", WEBrick::Utils::getservername]],
})
end
end
end
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
我在/config/environments/production.rb中添加了以下行:
config.force_ssl = true
使用两个不同的pid在80和443上启动rails:
SSL=true rails s -p 443 -e production
rails s -p 80 -P SERVER2 -e production
一切正常,但是10-12小时后,https协议停止响应浏览器,即使日志文件中没有任何添加内容。
您能否确认问题是什么?如何纠正?