Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Thin Web Server with HTTP and HTTPS

I'm using the Thin web server to serve my Rails app.

  • Starting the server with thin start serves http requests.
  • Starting the server with thin start --ssl serves https requests.

Is there a way to have thin serve both http and https requests concurrently?

The reason I ask is because when I use redirect_to some_path in my controllers, they redirect to http. Since thin is serving https requests, nothing is rendered.

Note: I'm using Rack::SSL in Rails 3.0.7.

like image 356
Graham Swan Avatar asked Mar 04 '12 23:03

Graham Swan


2 Answers

(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. 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.)

You can't accept both HTTP and HTTPS connections on the same port. (This is why, by default convention, HTTP runs on port 80 whereas HTTPS runs on port 443.)

like image 81
Jeremy Roman Avatar answered Oct 04 '22 13:10

Jeremy Roman


you can use foreman (https://github.com/ddollar/foreman);

You create a Procfile with 2 process then start both with forman start command.

put this on a file called Procfile:

web: thin start
ssl: thin start --ssl

Then use foreman start and he start the 2 process. This is how i am using... hope this helps you!

like image 43
Rudiney Franceschi Avatar answered Oct 04 '22 14:10

Rudiney Franceschi