ngrok无法正常工作以测试HTTP [英] ngrok not working correctly to test HTTPs

查看:302
本文介绍了ngrok无法正常工作以测试HTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了ngrok,以便可以测试我的网站是否有http和https请求(如果有人试图进入我的网站特定网址,并且这将是一个简单的http请求,我会拒绝它),

I downloaded ngrok so i can test my site for http and https requests (if someone is trying to get in my site specific url and it will be a simple http request, i will deny it),

首先,我的本地主机在8080端口中工作

first, my localhost is working in 8080 port

我启动ngrok,它给了我以下内容:

I start ngrok, it gives me the following:

在同一个端口上,我都认为这是一个问题,因为如果我在laravel中进行如此简单的路由配置:

both at the same port, it's a problem i think, because if i do such simple route configuration in laravel:

Route::filter('force.ssl', function()
{
    if( ! Request::secure())
    {
        return 'unsecured';
    }

});

我有这条路线:

Route::get('survey/payment/secured', array('before' => 'force.ssl', function(){
   return 'secured!';
}));

我要执行以下请求:

https://75fdaa96.ngrok.com/survey/payment/secured

它认为它是不安全的,并返回不安全",我该如何解决?

it thinks it unsecured and returns 'unsecured', how can i fix this?

推荐答案

Request::secure()依赖$_SERVER['HTTPS'].由于HTTPS是由代理而不是您的Web服务器提供的,因此Laravel不知道它是作为HTTPS提供服务的.

Request::secure() relies on $_SERVER['HTTPS']. As the HTTPS is being provided by the proxy, not your webserver, Laravel doesn't know it's being served as HTTPS.

ngrok 确实传递了X-Forwarded-Proto标头,但Laravel不信任默认情况下.您可以使用受信任的代理中间件对其进行信任.

ngrok does pass the X-Forwarded-Proto header, but Laravel doesn't trust it by default. You can use the trusted proxy middleware to trust it.

这篇关于ngrok无法正常工作以测试HTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆