如何使用 Rails 脚本/服务器测试 HTTPS?

发布于 2024-07-11 14:50:34 字数 1496 浏览 3 评论 0原文

我需要在开发中测试与本地 Rails 脚本/服务器实例的 HTTPS 连接,它似乎不受支持,而且我无法通过 Google 搜索任何解决方案。

从客户端的角度来看,它是这样的:

ted@teflon-ted ~/Downloads[master]$ grep tedslaptop /etc/hosts
127.0.0.1   api.tedslaptop.com
ted@teflon-ted ~/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\000@\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: {}
---

I need to test HTTPS connections to my local Rails script/server instance in development it doesn't seem to be supported and I wasn't able to Google-up any solutions.

Here's what it looks like from the client perspective:

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

And here's what I see on the server:

$ 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\000@\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: {}
---

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

停滞 2024-07-18 14:50:34

HTTPS 是在 Rails 框架之外处理的东西。 因此,您不能直接测试它。 Rails 应用程序在 HTTPS 上提供的功能应该与在未加密的 HTTP 上提供的功能完全相同。

script/server 使用 Mongrel 来满足您的请求。 Mongrel 不直接支持 SSL/HTTPS。

如果您确实想测试 HTTPS 功能,则必须设置具有 SSL/HTTPS 支持的 Apache(或其他 Web 服务器)(使用 mod_ssl),并将其配置为运行 Rails 应用程序(使用 mod_rails 或 mod_proxy)。

HTTPS is something that is handled outside the Rails framework. Therefore, you cannot test it directly. The functionality that your Rails application provides should be exactly the same on HTTPS as it is on unencrypted HTTP.

script/server uses Mongrel to serve your requests. Mongrel does not support SSL / HTTPS directly.

If you really want to test HTTPS functionality, you have to setup Apache (or another webserver) with SSL/HTTPS support (using mod_ssl), and configure it to run your Rails application (using mod_rails or mod_proxy).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文