1

Specs: Rails 4.2.4, Ruby 2.1.9, running puma, EC2 instance in production mode

I have an SSL certificate that I want to install on my server but using techniques like this one yields no results

rails s puma -b 'ssl://0.0.0.0:9292?key=path_to_key.key&cert=path_to_cert.crt&verify_mode=none&ca=path_to_root_bundle.crt'

How to configure Rails with Puma to use SSL?

also

RAILS_ENV=production rvmsudo -E rails s puma -b "ssl://0.0.0.0:9292?key=${KEY_PATH}&cert=${CERT_PATH}&verify_mode=peer&ca=${CERT_BUNDLE_PATH}" -p 80 

Instead of a functioning server I get

Puma starting in single mode... * Version 3.2.0 (ruby 2.1.9-p490), codename: Spring Is A Heliocentric Viewpoint * Min threads: 0, max threads: 16 * Environment: production * Listening on tcp://ssl://0.0.0.0:9292?key=~/evslideshow.key&cert=~/e3b162f57ea48f91.crt&verify_mode=peer&ca=~/gd_bundle-g2-g1.crt:80 Exiting > /home/ec2-user/.rvm/gems/ruby-2.1.9@slideshow/gems/puma-3.2.0/lib/puma/binder.rb:240:in `initialize': getaddrinfo: Name or service not known (SocketError)

Now my mind is playing with different options. Am I just missing some fundamental aspect of using puma here? The puma documentation is very scared which is why I'm asking here. Or I could use Nginx because it seems like there is alot of documentation on the internets on setting that up with SSL certificate.

If there is a simpler fix for puma then I will just use that.

1 Answer 1

1

Found the solution by reading through some of the issue pages on puma's Github page. Apparently we must call puma directly, and not through rails server, despite what was said here in this old stackoverflow answer

The working code is

RAILS_ENV=production rvmsudo -E puma -d -b "ssl://0.0.0.0:443?key=${KEY_PATH}&       
cert=${CERT_PATH}&verify_mode=peer&ca=${CERT_BUNDLE_PATH}" -p 80 

Make sure to turn on config.force_ssl in your production config file as well.

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.