Ngrok 和 Laravel
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43490688/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NGrok and Laravel
提问by Kaherdin
I want to deploy my local larvel website online with NGROK. I'm using Laragon with Apache server, I use this command :
我想使用 NGROK 在线部署我的本地 larvel 网站。我在 Apache 服务器上使用 Laragon,我使用以下命令:
ngrok http -host-header=rewrite site.dev:80
It almost work, but the asset file (like CSS/Image) are still link to my local server (site.dev). And it's the same for my link, the laravel routing command :
{{ route('ngo') }}
return site.dev/ngo instead of my online tunnel (http://number.ngrok.io/ngo)
它几乎可以工作,但资产文件(如 CSS/Image)仍然链接到我的本地服务器(site.dev)。我的链接也是一样的,laravel 路由命令:
{{ route('ngo') }}
返回 site.dev/ngo 而不是我的在线隧道(http://number.ngrok.io/ngo)
I've try to :
我尝试:
Edit the http.conf (https://forum.laragon.org/topic/88/allow-outside-other-devices-phones-tablets-to-access-your-local-server-using-ngrok)
编辑 http.conf ( https://forum.laragon.org/topic/88/allow-outside-other-devices-phones-tablets-to-access-your-local-server-using-ngrok)
Change my Laravel App url in config/app.php
在 config/app.php 中更改我的 Laravel App url
Change my url in .env file
在 .env 文件中更改我的网址
Nothings work
无事可做
回答by greew
I ran into this problem myself just now, but also found a way to fix it:
刚刚我自己也遇到了这个问题,不过也找到了解决的方法:
Run the ngrok command without the -host-header=rewrite
part, resulting in
运行没有-host-header=rewrite
零件的 ngrok 命令,导致
ngrok http site.dev:80
ngrok http site.dev:80
After this, edit your http.conf file and add the ngrok domain as a server alias. For example:
在此之后,编辑您的 http.conf 文件并将 ngrok 域添加为服务器别名。例如:
ServerAlias nd3428do.ngrok.io
ServerAlias nd3428do.ngrok.io
The problem is that Laravel's route
helper uses the HOST
header, which is rewritten to site.dev
. Without the -host-header
part, the header isn't rewritten and now it works.
问题是 Laravel 的route
助手使用了HOST
头文件,它被重写为site.dev
. 没有这个-host-header
部分,标题不会被重写,现在它可以工作了。