[英]Ngrok with vagrant doesn't work in windows 10
I'm trying to expose my local server through ngrok.我正在尝试通过 ngrok 公开我的本地服务器。 I'm using vagrant to run my project in my localserver so, I read that there is a plugin for vagrant and ngrok, "vagrant share".
我正在使用 vagrant 在我的本地服务器上运行我的项目,所以,我读到有一个 vagrant 和 ngrok 插件,“vagrant share”。 I already downloaded ngrok but when I run the command vagrant share, this is the result :
我已经下载了 ngrok,但是当我运行命令 vagrant share 时,结果如下:
The executable 'ngrok' Vagrant is trying to run was not found in the PATH variable.
在 PATH 变量中找不到试图运行的可执行文件 'ngrok' Vagrant。 The 'ngrok' executable is required to run Vagrant share.
运行 Vagrant 共享需要“ngrok”可执行文件。 If 'ngrok' is currently installed in a non-standard location, append that location to the PATH variable and run this command again.
如果“ngrok”当前安装在非标准位置,请将该位置附加到 PATH 变量并再次运行此命令。
I already put ngrok in the environment variable but it doesn't work.我已经将 ngrok 放在环境变量中,但它不起作用。
Any idea how to fix it?知道如何修复它吗? I have several days with this problem and I can't solve it.
我有好几天遇到这个问题,但无法解决。
您是否尝试过手动安装vagrant share
插件?
vagrant plugin install vagrant-share
You have to explicitly have ngrok in your Windows PATH.您必须在 Windows PATH 中明确包含 ngrok。 I suspect the
vagrant share
plugin does not install ngrok
.我怀疑
vagrant share
插件没有安装ngrok
。
To do this same thing for myself, I happened to be running with Visual Studio Code, using PowerShell as the Terminal.为了为自己做同样的事情,我碰巧在运行 Visual Studio Code,使用 PowerShell 作为终端。 I downloaded ngrok in zip form from the ngrok web site, extracted, placed it in my Windows home directory, and added that to the PowerShell path.
我从 ngrok 网站下载了 zip 格式的 ngrok,将其解压缩,放在我的 Windows 主目录中,然后将其添加到 PowerShell 路径中。 Then
vagrant share
immediately worked (I did not have to explicitly setup an authtoken or connect an account).然后
vagrant share
立即起作用(我不必明确设置 authtoken 或连接帐户)。 Below substitute windowsuser
with your account id.下面用您的帐户 ID 替换
windowsuser
。
c:\\Users\\windowsuser
c:\\Users\\windowsuser
$env:Path += ";c:\\users\\windowsuser"
$env:Path += ";c:\\users\\windowsuser"
PS C:\Users\windowsuser\vagrant_getting_started> ngrok
NAME:
ngrok - tunnel local ports to public URLs and inspect traffic
DESCRIPTION:
ngrok exposes local networked services behinds NATs and firewalls to the
public internet over a secure tunnel. Share local websites, build/test
webhook consumers and self-host personal services.
Detailed help for each command is available with 'ngrok help <command>'.
Open http://localhost:4040 for ngrok's web interface to inspect traffic.
EXAMPLES:
ngrok http 80 # secure public URL for port 80 web server
ngrok http -subdomain=baz 8080 # port 8080 available at baz.ngrok.io
ngrok http foo.dev:80 # tunnel to host:port instead of localhost
ngrok http https://localhost # expose a local https server
ngrok tcp 22 # tunnel arbitrary TCP traffic to port 22
ngrok tls -hostname=foo.com 443 # TLS traffic for foo.com to port 443
ngrok start foo bar baz # start tunnels from the configuration file
VERSION:
2.3.35
AUTHOR:
inconshreveable - <alan@ngrok.com>
COMMANDS:
authtoken save authtoken to configuration file
credits prints author and licensing information
http start an HTTP tunnel
start start tunnels by name from the configuration file
tcp start a TCP tunnel
tls start a TLS tunnel
update update ngrok to the latest version
version print the version string
help Shows a list of commands or help for one command
PS C:\Users\windowsuser\vagrant_getting_started>
vagrant share
should work;vagrant share
应该可以工作; as you can see, I am working through the vagrant tutorials.PS C:\Users\windowsuser\vagrant_getting_started> vagrant share
==> default: Detecting network information for machine...
default: Local machine address: 127.0.0.1
default:
default: Note: With the local address (127.0.0.1), Vagrant Share can only
default: share any ports you have forwarded. Assign an IP or address to your
default: machine to expose all TCP ports. Consult the documentation
default: for your provider ('virtualbox') for more information.
default:
default: Local HTTP port: 4567
default: Local HTTPS port: disabled
default: Port: 2200
default: Port: 4567
==> default: Creating Vagrant Share session...
==> default: HTTP URL: http://e058e1d1b464.ngrok.io
==> default:
C:\Users\windowsuser>set PATH=%PATH%;C:\Users\windowsuser
In your $PATH provide only the path to where ngrok binary executable can be found.在您的 $PATH 中仅提供可以找到 ngrok 二进制可执行文件的路径。 For example:
/path/to
is correct , and not /path/to/ngrok
例如:
/path/to
是正确的,而不是/path/to/ngrok
At least that was my mistake at first.至少那是我一开始的错误。 Hope that detail helps to someone.
希望这个细节对某人有帮助。 In principle @learning2learn 's answer is correct.
原则上@learning2learn 的答案是正确的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.