opcodesio / log-viewer

Fast and beautiful Log Viewer for Laravel
https://log-viewer.opcodes.io
MIT License
3.51k stars 253 forks source link

LogViewer::auth not working behind proxy #396

Open btxtiger opened 3 weeks ago

btxtiger commented 3 weeks ago

Not sure why it is the case, but when Laravel runs with Octane as reverse proxy (in production),

\LogViewer::auth(fn () => auth()->check());

does not work and always leads to a 403 error, while

\Gate::define("viewLogViewer", fn () => auth()->check());

works fine.

PHP-FPM did not have this issue. I tested if it is a remote_addr related thing, by mapping it to the real IP instead of the Docker IP (real_ip_header X-Forwarded-For;), but it didn't help.

A-Moussa0 commented 1 day ago

I faced the same issue, but even with Gate, I am able to access the viewer but not see the list of log files

A-Moussa0 commented 1 day ago

I faced the same issue, but even with Gate, I am able to access the viewer but not see the list of log files

Here is actually the problem I am describing, it seems to have already been fixed. I will the proposed solution a try https://github.com/opcodesio/log-viewer/issues/366

arukompas commented 17 hours ago

This might be due to configuration of the proxy. You must forward authorisation and host headers, otherwise Laravel might deny the request.

Dump your request headers in any controller, and make sure you still receive the "Authorization" header, as well as the Host is set to the same as your "APP_URL" variable, or at least the host is added to the "LOG_VIEWER_API_STATEFUL_DOMAINS" variable

https://log-viewer.opcodes.io/docs/3.x/configuration/route-and-domain#production-domains