简体   繁体   English

SQL服务器访问如何配置ngrok

[英]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.我想针对本地计算机上的 sql 服务器实例测试在远程位置托管的开发中的网站。 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.我想我可以在本地运行 ngrok 并适当地更新远程网站上的连接字符串,但我不确定我需要指定哪些参数。

I've tried ngrok tcp 12345 and ngrok http 12345我试过ngrok tcp 12345ngrok 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).在 SQL 服务器配置管理器中,我为我要使用的 SQL Express 实例启用了 TCP/IP,并将端口设置为侦听 12345(实际上,一个不同的数字,但为了这篇文章,我们会说 12345) . And I then restarted SQL Server.然后我重新启动了 SQL 服务器。

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.为了在本地进行测试,我使用 ngrok 提供的 url 并将其放入 SQL Management Studio 的连接对话框中,但我无法连接它。

What am I missing?我错过了什么?

  1. Set up Ngrok设置 Ngrok
  2. Run ngrok on tcp on the SQL port (by default is 1433) ngrok tcp 1433在 SQL 端口(默认为 1433)上运行 tcp 上的ngrok tcp 1433

You will get an url like tcp://3.tcp.ngrok.io:12345你会得到一个 url 像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://服务器名称: 3.tcp.ngrok.io,12345注意端口和 url 之间的逗号。键入 url 而不是tcp://
  • Login: your regular user, in my case sa and your password登录:您的普通用户,在我的例子中sa和您的密码
  • Connect连接

The "URL" that ngrok generates for a TCP tunnel probably shouldn't be used unmodified. ngrok 为 TCP 隧道生成的“URL”可能不应该未经修改地使用。 The tcp:// scheme part isn't a URI scheme in common use I don't think.我不认为tcp://方案部分不是常用的 URI 方案。 Only the hostname and port part of the generated ngrok "URL" would be useful in a SQL Server connection configuration.只有生成的 ngrok“URL”的主机名和端口部分在 SQL 服务器连接配置中才有用。

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?不熟悉 SQL Management Studio 中引用的连接对话框,很难准确地说出预期的输入是什么,但也许tcp://方案就可以了?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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