4

I am currently using rails 5.2.1. When I start my rails server I do:

rails s -p 3000 -b x.x.x.x(ip) -e production -d

This will start the rails server which is using puma. Is there a way I can use SSL with my rails app?

3 Answers 3

7

Don't expose Puma directly to the internet - puma is designed under the assumption that it will be behind a reverse proxy, such as nginx.

The nginx layer will provide your application with another layer or protection and has the added benefit of significantly speeding up any static files your application might serve (assets).

You can use SSL/TLS, using puma's -b option (try puma -help), but unless you have another option, I would avoid that.

Just to clarify, I'm the author of the iodine HTTP / WebSocket Ruby server, which also supports SSL/TLS... consider this advice as very informed: I recommend a reverse proxy.

6

As long as you have the local keys somewhere in your config directory you should be able to do:

rails s puma -p 3000 -b 'ssl://0.0.0.0:3000?key=config/your_key_file.key&cert=config/your_certificate_file.crt'

If you need to know how to generate a local certificate and key this is a good post: https://rossta.net/blog/local-ssl-for-rails-5.html#create-a-self-signed-certificate

1

I'm using gem called tunnels, check it out here: https://github.com/jugyo/tunnels

It is a proxy to http from https on your local machine. Also no keys needed.

Hope it helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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