Moodle behind TLS offload needs $CFG->sslproxy
Moodle™ sees the request PHP received. If nginx, HAProxy, an F5, or Cloudflare terminates TLS and the PHP pool speaks HTTP on localhost, $_SERVER['HTTPS'] is empty. $CFG->wwwroot is still https://lms.example.org . Login then 302-loops, cookies drop the Secure flag, and generated URLs flip to http:// . config-dist.php names the switch: // Enable when using external SSL appliance for performance…
Moodle requires $CFG- sslproxy to be set to true when using an external SSL appliance for performance reasons. This flag allows Moodle to generate HTTPS URLs even if the PHP pool is accessed via HTTP on localhost. If this flag is missing, users may encounter issues such as 302 loops, mixed-content warnings, and session cookies without the Secure flag.
When $CFG- sslproxy is enabled, Moodle will not set the Strict-Transport-Security (HSTS) header, which should be set at the TLS terminator level instead. The $CFG- wwwroot must match the URL students type, including "https://" with no trailing slash. If both $CFG- sslproxy and $CFG- reverseproxy are enabled, Moodle may refuse access with an error message.
To ensure proper functionality, it is essential to redirect HTTP traffic to HTTPS using a redirect rule on the TLS terminator. Health checks should be performed over the internal HTTP port from the private network, using a Host header, without publishing that port. Additionally, running cURL commands after every proxy change and after cloning the stack into a new cluster is recommended to prevent mixed-content issues.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.