Laravel Community Tools by Tighten

zOxta

Joined: 11 years ago
Total tricks: 3
Last trick: 11 years ago

Submitted tricks

If you are running Laravel 4 behind Cloudflare over HTTPS some functions like ‘Request::secure()’ and ‘Request::isSecure()’ will return false. By using the setTrustedProxies method of the Request facade we can add the Cloudflare IP ranges to trust, thus the Request class will honor the ‘X-Forwarded-Proto’ and other ‘X-Forwarded’ headers.
zOxta 11 years ago 10741
If you are running Laravel 4 and behind a load balancer or a reverse proxy, some HTTPS functions like ‘Request::secure()’ and ‘Request::isSecure()’ will return false. If we add the current IP which belongs to the proxy/load balancer to the setTrustedProxies then the Request class will honour the ‘X-Forwarded-Proto’ and other ‘X-Forwarded’ headers and the mentioned functions would work fine. Note: THIS METHOD CANNOT BE TRUSTED unless ALL requests go through a proxy YOU control.
zOxta 11 years ago 25085
If you want to redirect all HTTP traffic to HTTPS (SSL) you can use this method. However, note that this may NOT work out of the box if you are behind CloudFlare/load balancer/reverse proxy unless you set a trusted proxy, more info here: http://www.laravel-tricks.com/tricks/fix-ssl-in-laravel-4-when-server-is-behind-a-load-balancer-or-a-reverse-proxy
zOxta 11 years ago 32838