2009-01-16 29 views
9

我需要在開發中測試HTTPS連接到我本地的Rails腳本/服務器實例,但似乎沒有得到支持,我無法谷歌上任何解決方案。如何使用Rails腳本/服務器測試HTTPS?

下面是它看起來像從客戶角度:

 
[email protected] ~/Downloads[master]$ grep tedslaptop /etc/hosts 
127.0.0.1 api.tedslaptop.com 
[email protected] ~/Downloads[master]$ /usr/bin/curl https://api.tedslaptop.com:3000/ 
curl: (35) Unknown SSL protocol error in connection to api.tedslaptop.com:3000 

這裏就是我在服務器上看到:

 
$ script/server 
=> Booting Mongrel (use 'script/server webrick' to force WEBrick) 
=> Rails 2.2.2 application starting on http://0.0.0.0:3000 
=> Call with -d to detach 
=> Ctrl-C to shutdown server 
** Starting Mongrel listening at 0.0.0.0:3000 
** Starting Rails with development environment... 
** Rails loaded. 
** Loading any Rails specific GemPlugins 
** Signals ready. TERM => stop. USR2 => restart. INT => stop (no restart). 
** Rails signals registered. HUP => reload (without restart). It might not work well. 
** Mongrel 1.1.5 available at 0.0.0.0:3000 
** Use CTRL-C to stop. 
Fri Jan 16 13:06:50 -0500 2009: HTTP parse error, malformed request (127.0.0.1): # 
Fri Jan 16 13:06:50 -0500 2009: REQUEST DATA: "\200d\001\003\001\000K\000\000\000\020\000\0009\000\0008\000\0005\000\000\026\000\000\023\000\000\n\a\000?\0003\000\0002\000\000/\003\000\200\000\000\005\000\000\004\001\000\200\000\000\025\000\000\022\000\000\t\006\[email protected]\000\000\024\000\000\021\000\000\b\000\000\006\004\000\200\000\000\003\002\000\200xa\377\\?wEM??/\235F\020\232" 
--- 
PARAMS: {} 
--- 
+0

使用apache和mod_rewrite – 2009-01-16 18:14:59

回答

14

HTTPS的東西是Rails框架之外處理。因此,你不能直接測試它。您的Rails應用程序提供的功能在HTTPS上應與在未加密的HTTP上完全相同。

腳本/服務器使用Mongrel來爲您的請求提供服務。 Mongrel不直接支持SSL/HTTPS。

如果你真的想測試HTTPS功能,你必須設置阿帕奇(或另一個網站服務器)與SSL/HTTPS支持(使用mod_ssl),並將其配置爲運行Rails應用程序(使用mod_railsmod_proxy)。

相關問題