Running SSL in Development Environment


I am building an application that consists of two areas; a website and
an API. I would like the website to use HTTP and the API to use HTTPS.
How can I set this up for my Development Environment?

I am using Thin, which I can start using the --SSL flag. However this
means any HTTP urls will fail. As far as I can see it is impossible to
have a server handle both HTTP and HTTPS, so how do people develop an
application that uses SSL locally?


Why not just do what you would do in production: put an SSL-capable
proxy (apache httpd, nginx, squid, etc.) in front of thin?

Alternatively, start 2 instances of thin on appropriate ports.



Thanks for your reply.

Would you mind elaborating on the these option? This is new ground for
me. I haven't used SSL before and I've never set up a production

It's common to use a web server like Apache httpd that can listen
on multiple ports, e.g. both 80 (http) and 443 (https) and proxy
requests to a back-end Rails server like thin, mongrel, unicorn. It's
not hard to configure and there are plenty of tutorials, I'm sure.
(You can also use nginx, squid, or some other proxy.)

And some people use Passenger (mod_rails) which gives you an
integrated Rails server with Apache httpd or nginx, eliminating the
backend/proxy part. Less flexible but fewer moving parts...

Either approach will work in production, so I'd look into both and
see what feels best to you.

Thanks Hassan.