简体   繁体   English

通过HTTP和HTTPS使用Thin Web Server

[英]Using Thin Web Server with HTTP and HTTPS

I'm using the Thin web server to serve my Rails app. 我正在使用Thin Web服务器来提供我的Rails应用程序。

  • Starting the server with thin start serves http requests. 使用thin start启动服务器可以提供http请求。
  • Starting the server with thin start --ssl serves https requests. 使用thin start --ssl启动服务器thin start --ssl提供https请求。

Is there a way to have thin serve both http and https requests concurrently? 有没有办法同时thin服务httphttps请求?

The reason I ask is because when I use redirect_to some_path in my controllers, they redirect to http . 我问的原因是因为当我在控制器中使用redirect_to some_path时,它们会重定向到http Since thin is serving https requests, nothing is rendered. 由于thin正在提供https请求,因此不会呈现任何内容。

Note: I'm using Rack::SSL in Rails 3.0.7 . 注意:我在Rails 3.0.7使用Rack::SSL

(Comment converted to answer as requested.) (评论转换为按要求回答。)

Simplest option is probably to run two separate instances of thin: one accepting SSL requests and one accepting plaintext requests. 最简单的选项可能是运行两个单独的瘦实例:一个接受SSL请求,一个接受明文请求。 Any reason you don't want to do this? 你有什么理由不想这样做吗? (Alternatively, if thin is running behind another web server, like Apache or Nginx, you only need one instance of thin: the frontend server can report whether the request came in over SSL.) (或者,如果瘦是在另一个Web服务器(如Apache或Nginx)后面运行,则只需要一个瘦实例:前端服务器可以报告请求是否通过SSL传入。)

You can't accept both HTTP and HTTPS connections on the same port. 您不能在同一端口上接受HTTP和HTTPS连接。 (This is why, by default convention, HTTP runs on port 80 whereas HTTPS runs on port 443.) (这就是为什么,默认情况下,HTTP在端口80上运行,而HTTPS在端口443上运行。)

you can use foreman (https://github.com/ddollar/foreman); 你可以使用工头(https://github.com/ddollar/foreman);

You create a Procfile with 2 process then start both with forman start command. 使用2进程创建Procfile,然后使用forman start命令启动它们。

put this on a file called Procfile : 把它放在一个名为Procfile的文件中:

web: thin start
ssl: thin start --ssl

Then use foreman start and he start the 2 process. 然后使用foreman start他开始2过程。 This is how i am using... hope this helps you! 这就是我的使用方式......希望这对你有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM