2013-06-20 48 views
7

我可以用細跟RubyMine的薄與SSL選項

bundle exec thin start --ssl --ssl-verify --ssl-key-file /private/etc/apache2/ssl/server.key --ssl-cert-file /private/etc/apache2/ssl/server.crt 

它可以在控制檯/終端,完美

但是,當我嘗試添加在「運行/調試配置」中的RubyMine這些選項 - >「編輯腳本參數」我得到:

/Users/jan/.rbenv/versions/1.9.3-p392/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/jan/RubymineProjects/myapp/script/rails server thin -b 0.0.0.0 -p 3000 -e development --ssl-verify --ssl-key-file /private/etc/apache2/ssl/server.key --ssl-cert-file /private/etc/apache2/ssl/server.crt 
/Users/jan/.gem/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/server.rb:33:in `parse!': invalid option: --ssl-verify (OptionParser::InvalidOption) 
from /Users/jan/.gem/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:283:in `parse_options' 
from /Users/jan/.gem/ruby/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:180:in `options' 
from /Users/jan/.gem/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/server.rb:54:in `set_environment' 
from /Users/jan/.gem/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands/server.rb:42:in `initialize' 
from /Users/jan/.gem/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in `new' 
from /Users/jan/.gem/ruby/1.9.1/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>' 
from /Users/jan/RubymineProjects/myapp/script/rails:6:in `require' 
from /Users/jan/RubymineProjects/myapp/script/rails:6:in `<top (required)>' 
from -e:1:in `load' 
from -e:1:in `<main>' 

過程與退出代碼完成1 誰能幫我們/我嗎?

非常感謝!

+0

不能SSL密鑰和證書文件中薄的配置文件(YAML)指定一個新的日誌文件? –

回答

1

選項的Ruby腳本來做到這一點--ssl-verify不應該被用來

4

使用以下方式

require 'rack' 

SERVER_KEY = File.expand_path('../../ssl-cert/host.key', __FILE__) 
SERVER_PEM = File.expand_path('../../ssl-cert/host.crt', __FILE__) 

# Thin SSL workaround 
module Rack 
    module Handler 
    class Thin 
     def self.run(app, options={}) 
     app = Rack::Chunked.new(Rack::ContentLength.new(app)) 
     server = ::Thin::Server.new(options[:Host] || '0.0.0.0', 
            options[:Port] || 3000, 
            app) 
     server.ssl = true 
     server.ssl_options = { 
      :private_key_file => SERVER_KEY, 
      :cert_chain_file => SERVER_PEM 
     } 
     yield server if block_given? 
     server.start 
     end 
    end 
    end 
end 
# Workaround end 

APP_PATH = File.expand_path('../../config/application', __FILE__) 
require File.expand_path('../../config/boot', __FILE__) 
require 'rails/commands' 
+0

從[此Github評論](https://gist.github.com/masone/5955f4cc0b4d4ef372db#gistcomment-1448440),如果您希望Thin使用其內置的自簽名證書,則可以將'nil'傳遞給': private_key_file'和':cert_chain_file'。 – Aaroninus

0

顯然,這實際上可以通過添加Procfile和創業板工頭被拉斷,在本組指令:

Using Rails, Thin and SSL in RubyMine: The solution!

基本上,你加工頭給您的Gemfile:

gem 'foreman' 

然後創建一個Procfile在裝有該根(鏈接拼錯此):

web: thin start --ssl 

,或者綁定到0.0.0.0作爲的RubyMine通常不會:

web: thin start -a 0.0.0.0 -p 3001 --ssl 

我並不需要指定的我受SSL文件的位置,但如果你想這將是:

web: thin start -a 0.0.0.0 -p 3001 --ssl --ssl-key-file /private/etc/apache2/ssl/server.key --ssl-cert-file /private/etc/apache2/ssl/server.crt 

我不會推薦使用--ssl-verify,因爲這對我無效。

最後,在RubyMine的,創建一個新的Ruby配置具有以下屬性:

  • Ruby腳本:這應該是路徑工頭可執行文件,例如:~/.rvm/gems/[email protected]/gems/foreman-0.82.0/bin/foreman
  • 腳本參數start
  • 工作目錄:您項目的根目錄,例如~/Sites/appname

在Bundler選項卡中,選中僅在運行時使用bundle exec複選框。

最後,在日誌選項卡上,添加指向~/Sites/appname/logs/development.log