When using Cloudflare to manage your site, you may notice that if you check the ip address of the request, it will be an ip address from Cloudflare. This is happening because Cloudflare is proxying the request to your server. To get around this issue and get the original request ip, you need to configure trusted proxies in Laravel.
This is important because the throttle middleware checks the request ip and throttles based on ip. If all request look like they are coming from Cloudflare, this will cause issues.
One option would be to allow all but I would not recommend this.
'proxies' => '*',
Another option would be to just hardcode all Cloudflare’s ip address. But what if they change?
'proxies' => [
The best option would be for the range of ip address to auto-update if they change. Fortunately, a great package exists that does just that.
Install the package and make sure you have the reload command set to run daily to ensure the range of ip address are up to date.
Be sure to check out the great article covering trusted proxies on Laravel News.
Thanks for reading. Make sure you follow me on Twitter to stay up to date on the progress of my side projects T.LY, Weather Extension, and Link Shortener Extension. If you are interested in the tech I use daily, check out my uses page.