All threads / Enable HTTPS SSL in rails localhost

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Enable HTTPS SSL in rails localhost

Lifanna asked in Rails
Good day, i tried to enable https secure connection for my rails application.
First of all, set config.force_ssl = true in application.rb only. So, re-started rails server, but there was error: "HTTP parse error, malformed request (): #<Puma::HttpParserError: Invalid HTTP format, parsing fails."
Also, i created SSL certificate with command: "openssl req -x509 -sha256 -nodes -newkey rsa:2048 -days 365 -keyout localhost.key -out localhost.crt" then put it in server directory.
Then started my server with command: rails s -b 'ssl://localhost:3000?key=path/to/file/localhost.key&cert=path/to/file/localhost.crt'
But i had new error
How should i solve this problem?( Are there any solutions of enabling https?

I'm havng the same problem and removing force_ssl doesn't fix it.

In the past I have used https://github.com/puma/puma-dev
They have pretty good instructions for how to make ssl work

i just run an ngrok server now.. spits everything out to https or http depending on your requirements

try using serveo.net(http://serveo.net/). It is amazing to use. You can also create custom domains by following command ssh -R <keyword-for-domain>:80:localhost:<port-number> serveo.net -o "ServerAliveInterval 30" -o "ServerAliveCountMax 3"

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 33,399+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.