Sometimes for test purposes, it is necessary to run dev server with ssl enabled. In my case, I had to test my paypal webhooks implementation and it was required by paypal to have https in url root to hook my system up with webhooks: Here is what we can do about it:
1) Navigate terminal to your rails project location. 2) Generate certificate-key pair bundle. It will ask questions but it's not required to answer them. Use the following command to actually generate the pair.
rails s -b 'ssl://localhost:3000?key=localhost.key&cert=localhost.crt'
In case you want to add it to rubymine:
Ok now if we start ether of servers above and access https://localhost:3000 we will be able to run in with fake ssl cert:
If you ran puma notice that now it has line with ssl:
Ok, this all looks good, but! What if we need to access our localhost from outside of our local network? Well here is what we can do:
1) Log in to your home router and find port forwarding settings: 2) #3 - puma that is my port forwarding settings for puma server. To make this all work we need to transfer 443(ssl) -> 3000 port. 443 is our outside port and 3000 our puma rails. 192.168.1.4 is my server IP address. Here is another more detailed screenshot: 3) Now we need to know our public IP address. Easy to check in google by asking what is my ip. 4) Accessing localhost from outside by using public ip:
Making this all work can be a bit wavy. Puma gave me a lot of trouble with ssl so I use thin in case I need to test paypal and regular puma when I need to test regular stuff. Hopefully it will save someone time.