Add \App\Http\Middleware\TrustProxies::class to $middleware in App\Http\Kernel?
https://laravel.com/docs/7.x/requests#configuring-trusted-proxies
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, when I login using wrong credentials I am redirected back to the root page (my.domain.com/) this does not happen in my local environment. If I go directly to the server I get 413 errors (I have APP_URL and session domain set in the config to the published domain)
Proxy setup (Nginx) I do https -> https if this could be the issue let me know.
location / {
proxy_pass https://<internal-server>:8081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Port 443;
proxy_set_header X-Forwarded-Host $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-VerifiedViaNginx yes;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect off;
}
What can the issue be? I can see that the IP's are correct in the logs of nginx on the webserver and the logs of laravel which logs failed logins with IP's.
EDIT forgot to say that I have added this
app/Http/Middleware/TrustProxies.php
/**
* The trusted proxies for this application.
*
* @var array|string
*/
protected $proxies;
/**
* The headers that should be used to detect proxies.
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
public function __construct(Repository $config)
{
$this->proxies = config('trustedproxy.proxies');
parent::__construct($config);
}
and config (config/trustedproxy.php)
...
'proxies' => explode(',', env('TRUSTED_PROXIES')),
...
env
TRUSTED_PROXIES=***proxy-server-ip***
It had to do with strict policy headers, not sure what does what in there as I just copied some security dudes setup. I now used some less strict setup and it works.
Please or to participate in this conversation.