ruby-on-railshttpsdnsssl-certificatengrok

Serving https from local through ngrok with domain


Apologies for my lack of clear understanding about SSL.

I would like my rails app to be accessible from the outside world with ngrok via https. In order to achieve this, I am using ngrok (enterprise) with the following command:

ngrok tls --domain=my.domain.com 3000

For my rails app to serve the website with TLS I use:

rails s -b 'ssl://localhost:3000?key=localhost.key&cert=localhost.crt'

The localhost.key and localost.crt have been generated on my computer. Needless to say that this works when trying to open https://127.0.0.1:3000/ (albeit with a warning), but it does not work at all when using my.domain.com because of certificate issues NET::ERR_CERT_COMMON_NAME_INVALID.

I downloaded the certificate from ngrok, but they do not provide the key, so I'm a bit lost at this point.

How can I serve https pages from my local dev env when someone access my.domain.com without having certificate issues?


Solution

  • I could make it work!

    Add the domain on ngrok, create an edge and then use ngrok tunnel:

    ngrok tunnel --label edge=XXXX http://localhost:3000
    

    Start your server normally with rails s.

    That's all it took.