Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request::secure() not returning true though sever is set to https #7251

Closed
rajanrawal opened this issue Feb 3, 2015 · 2 comments
Closed

Comments

@rajanrawal
Copy link

As because not having control to set up ssl certificate, client has used https://www.cloudflare.com/ssl for ssl cerificate. My local xamp installation working fine with Request::secure(). while debugging I found locally i have set $_SERVER['HTTPS'] = on while there is no such key set on server though its https instead $_SERVER['HTTP_X_FORWARDED_PROTO'] = https. I have gone in to Illuminate\Http\Request library and landed in Symfony\Component\HttpFoundation\Request where I came to know isSecure() method by default using $_SERVER['HTTP_X_FORWARDED_PROTO'] = https. The whole game is setting up setTrustedProxies() and setTrustedHeaderName() . I have tried
Request::setTrustedHeaderName('client_proto', 'X_FORWARDED_PROTO'); though its returning false. Can you bit explore here what can be done to get Request::secure() return true if $_SERVER['HTTP_X_FORWARDED_PROTO'] = https is set. I found some solutions over here
dmikusa/cf-php-apache-buildpack#6 but want to know if other way available with laravel. Thanks!

@rajanrawal
Copy link
Author

You need to use setTrustedProxies. isSecure() condition first check that only. otherwise it wont work. for example

$could_flare_ips = array(
       '199.27.128.0/21',
       '173.245.48.0/20'
);
Request::setTrustedProxies($could_flare_ips);

For laravel you can add this code in App::before() filter

@GrahamCampbell
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants