Force generation of HTTP / HTTPS link if behind caching server

Submitted by Berend Iwema - 5 years ago

For example, if you are using a caching server which listens on HTTPS, which retrieves your content from another (local server) which isn't using HTTPS, your links might be generated as instead of the desired With this trick you can circumvent this.

//I've put the following in app/start/global.php:

// --- app/start/global.php --- //
// Set the trusted proxies so we can generate HTTPS routes - in my case,
// --- app/start/global.php --- //

Now, ensure the caching server forwards the following header to the instance which serves your Laravel app:
X-Forwarded-Proto: https (or http if that is what you desire)

In case of an upstream in nginx, this would be:
proxy_set_header   X-Forwarded-Proto $scheme;
comments powered by Disqus