ngrok not working correctly to test HTTPs

柔情痞子 提交于 2019-12-01 09:43:14

问题


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),

first, my localhost is working in 8080 port

I start ngrok, it gives me the following:

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';
    }

});

and i have this route:

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

and i do the following request:

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

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


回答1:


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 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.



来源:https://stackoverflow.com/questions/26608117/ngrok-not-working-correctly-to-test-https

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!