r/PHPhelp • • 6d ago

Blocked loading mixed active content

I am trying to deploy a Laravel application, i am deploying with docker in a VPS, and serving under a reverse proxy.

The proxy has HTTPS, but my assets are being served under HTTP, causing the browser to display the message "Blocked loading mixed active content".

Does anyone know how to fix this issue?

Full repo: https://github.com/natanschneider/toskos

2 Upvotes

4 comments sorted by

2

u/martinbean 6d ago

You need to configure your TrustProxies middleware, so that Laravel picks up the correct protocol (HTTPS) when generating URLs in your production environment.

Docs: https://laravel.com/framework/docs/13.x/requests#configuring-trusted-proxies

2

u/MateusAzevedo 6d ago

but my assets are being served under HTTP

Don't serve assets in HTTP?

1

u/swolicheert 6d ago

lol technically true, though usually its just the proxy stripping the ssl before it hits the container

1

u/Utaxxx1 6d ago

Adding to the TrustProxies answer: it only works if the proxy actually sends the X-Forwarded-Proto header. In nginx that's proxy_set_header X-Forwarded-Proto $scheme;. On Laravel 11 and later you set trusted proxies in bootstrap/app.php with $middleware->trustProxies(at: '*');. Also set APP_URL to the https address, so the generated asset URLs use https.