I have been looking all over and either I can't find anything or I can't find anything that works... so here I am.

How can I go about setting up SSL/HTTPS with regards to Mongrel?

Thanks in advance!

link|improve this question
feedback

3 Answers

You run it through a real webserver first, like nginx or Apache, which does the SSL work for you, and then passes back a header saying whether or not the connection was made via SSL (only important if you're doing things like redirecting if a needs-to-be-secure page was accessed without SSL).

In theory, I guess you could stick stunnel in front of mongrel and do it that way, but the reasons not to are huge and scary, so just don't.

link|improve this answer
so.... how do you do it? There is a total lack of tutorials on how to do this, and I'm getting frustrated, to say the least. – mmr Feb 3 '10 at 5:26
feedback

It should of course be noted that Mongrel simply "doesn't do" SSL itself.

link|improve this answer
feedback

I struggled with this for a while. Mongrel prefers 'The Ruby Way' which is different then the Apache way.

Configure Apache HTTP to serve HTTPS traffic. Then proxy the plaintext/HTTP connections on the backend.

  1. Install mod_proxy. I actually had to recompile httpd to include proxy support.

    LoadModule proxy_module modules/mod_proxy.so

    LoadModule proxy_http_module modules/mod_proxy_http.so

    LoadModule proxy_connect_module modules/mod_proxy_connect.so

  2. Use mod_rewrite's [proxy] parameter to rewrite all traffic to the Mongrel host. My host is a VirtualHost, with a name like 'ruby.example.org'.

    RewriteRule ^/(.*) http://127.0.0.1:3000/$1 [proxy]

  3. Restrict access to the proxy. See httpd.apache.org/docs/2.2/mod/mod_proxy.html#access


    <Proxy *>
 Order Deny,Allow
 Deny from all
 # Restrict access from my local network
 Allow from 192.168.0
    </Proxy>

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.