如何将SSL选项传递到“rails server”中?在Rails 3.0中? [英] How can I pass SSL options into "rails server" in Rails 3.0?

查看:93
本文介绍了如何将SSL选项传递到“rails server”中?在Rails 3.0中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法将SSL选项传递到rails server(在Rails 3.0.0上),使用自定义Rack配置或类似的东西?我正在尝试做两件事:

Is there a way to pass SSL options into "rails server" (on Rails 3.0.0), using a custom Rack config or something similar? I'm trying to do two things:


  1. 启用Cucumber运行涉及安全和非安全URL的测试,并且

  2. 让新开发人员变得简单,因此他们无需设置Apache并配置所有SSL /证书,甚至可以编写一行代码。

在2.3.8上,我们有一个分叉的脚本/服务器,可以在第二个端口上启动一个特殊的WEBrick,并提供所有适当的SSL选项。当然,当我尝试升级到Rails 3时会爆炸,所以我试图弄清楚如何解决这个问题,理想情况下这样做的方式不涉及任何事情。

On 2.3.8 we had a forked script/server that would start up a special WEBrick on a second port with all the appropriate SSL options. Of course that blew up when I tried upgrading to Rails 3, so I'm trying to figure out how to fix this, and ideally do it in a way that doesn't involve forking anything.

在我们的分叉脚本/服务器中,我们设置了如下选项:

In our forked script/server we were setting options like the following:

:SSLEnable        => true,
:SSLVerifyClient    => OpenSSL::SSL::VERIFY_NONE,
:SSLPrivateKey        => OpenSSL::PKey::RSA.new(File.open(current_dir + "/config/certs/server.key").read),
:SSLCertificate         => OpenSSL::X509::Certificate.new(File.open(current_dir + "/config/certs/server.crt").read),
:SSLCertName    => [ [ "CN", WEBrick::Utils::getservername ] ]

但我不知道如何在新框架中做到这一点。

but I don't know how to do that in the new framework.

感谢您的帮助!

推荐答案

查看服务器代替WEBrick。使用Thin有很多好处,我不能在这里列出它们,但是它应该解决你的问题,因为它支持SSL。

Take a look at the Thin server in place of WEBrick. There are so many benefits of using Thin that I can't list them all here, but it should address your issue since it supports SSL.

启动 thin ,传递以下选项:

SSL options:
    --ssl                        Enables SSL
    --ssl-key-file PATH          Path to private key
    --ssl-cert-file PATH         Path to certificate
    --ssl-verify                 Enables SSL certificate verification

在生产中,理想情况下,您希望在Nginx或Apache层处理SSL,但这应该可以满足您的开发需求。

In production, you will ideally want to handle SSL at the Nginx or Apache layer, but this should handle your development requirements.

这篇关于如何将SSL选项传递到“rails server”中?在Rails 3.0中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆