简体   繁体   中英

How to configure ngrok for SQL Server access

I would like to test a website in development hosted in a remote location against a sql server instance on my local machine. I was thinking I could run ngrok locally and update the connection string on the remote website appropriately, but I'm not sure what parameters I need to specify.

I've tried ngrok tcp 12345 and ngrok http 12345

In SQL Server Configuration Manager I've enabled TCP/IP for the SQL Express instance I want to use and set the port to listen on to 12345 (actually, a different number, but we'll say 12345 for the sake of this post). And I then restarted SQL Server.

I don't believe it's necessary for me to make holes in the firewall, but just in case I've temporarily disabled it entirely while I test this.

To test locally, I am taking the url ngrok provides and putting it in the connection dialog in SQL Management Studio, but I can't get it to connect.

What am I missing?

  1. Set up Ngrok
  2. Run ngrok on tcp on the SQL port (by default is 1433) ngrok tcp 1433

You will get an url like tcp://3.tcp.ngrok.io:12345

In the "Connect to Server Dialog" type:

  • Server name: 3.tcp.ngrok.io,12345 Notice the comma between the port and the url. Type the url without tcp://
  • Login: your regular user, in my case sa and your password
  • Connect

The "URL" that ngrok generates for a TCP tunnel probably shouldn't be used unmodified. The tcp:// scheme part isn't a URI scheme in common use I don't think. Only the hostname and port part of the generated ngrok "URL" would be useful in a SQL Server connection configuration.

Not being intimately familiar with the referenced connection dialog in SQL Management Studio, it's hard to say exactly what input is expected, but maybe stripping out the tcp:// scheme will do the trick?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM