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:
paypal dashboard
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: Screen Shot 2019-08-31 at 11.53.52 PM.png46.4 KB Screen Shot 2019-08-31 at 11.54.25 PM.png73.9 KB
Screen Shot 2019-08-31 at 11.54.42 PM.png507 KB 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:
Screen Shot 2019-08-31 at 11.57.54 PM.png627 KB If you ran puma notice that now it has line with ssl: Screen Shot 2019-08-31 at 11.58.20 PM.png102 KB
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:Screen Shot 2019-09-01 at 12.02.16 AM.png141 KB 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: Screen Shot 2019-09-01 at 12.04.59 AM.png27.2 KB 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: Screen Shot 2019-09-01 at 12.10.54 AM.png233 KB
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.