3

My rails app is spin up using puma-dev on Ubuntu.

I'm using puma-dev command to start my app (in foreground) and then access the rails app using https://app.test:9283. As the puma-dev is running in the foreground I have to use the port 9283 to access the port.

Now I want to access the rails app on remote machines like a mobile device or other PC. So have to use the ngrok to do so. I have installed ngrok in my ubuntu but I'm not able to access my localhost setup running on https://app.test:9283 using ngrok. Any help would be appreciated!

NOTE: When I use ./ngrok http 80 it successfully redirects me to localhost:80 which means ngrok is working properly.

Milind
  • 4,535
  • 2
  • 26
  • 58
  • I haven't use ngrok in a couple of years, but I remember running "rails s -b 0.0.0.0" and then "ngrok http 3000", by my understand ngrok will tunnel your open port to a temp address on the port 80, so you should be going to app.test instead of app.test:3000 and the addresses were like #####.ngrok.io, you could change the port with something like "rails s -b 0.0.0.0 -p 3001" – Alexis Sep 11 '20 at 15:29
  • What command are you running to start `ngrok`? It could be something like `ngrok http 9283`. – Jake Worth Sep 11 '20 at 20:26
  • running `ngrok http 9283` gives me `Client sent an HTTP request to an HTTPS server.` – Tushar Bhutada Sep 12 '20 at 09:11

4 Answers4

3

With puma-dev it is necessary to include the -host-header argument, like so:

./ngrok http -host-header=app.test 9283
mrt
  • 1,669
  • 3
  • 22
  • 32
0

you have to bind the ngrok server with the same port as rails server ./ngrok http 9283

Priyanka
  • 39
  • 1
0

You need "local-leg HTTPS."

./ngrok http https://app.test:9283

0

The only way I was able to connect to my locally running app securely was by running the next command:

ngrok http https://app.localhost --host-header app.localhost

without any ports and the https:// address before the --host-header