2024年6月6日 星期四

Troubleshooting ngrok Connection Issues with Local Subdomains

Problem Description

I encountered difficulties getting ngrok version 3.10.0 to connect to my local subdomain despite trying various methods found online. The issue persisted until I came across this GitHub issue: “ngrok(ver.3) doesn’t work to tunnel localhost has subdomain.”

Environment Configuration

  • ngrok version: 3.10.0
  • Ruby on Rails version: 6.0.6.1
  • Local development URL: http://data.localhost.com:3000/

The Problem

The problem seems to be specific to Rails, which explains why commands that worked for others didn’t work in my case.

Solution

To resolve the issue, I used the following command:

ngrok http --host-header=rewrite http://data.localhost.com:3000/ --request-header-add=x_forwarded_host:data.localhost.com:3000

This command successfully established the ngrok tunnel for my local subdomain. If you’re experiencing similar issues with ngrok and Rails, give this solution a try.

沒有留言:

張貼留言