Hosting - Azure App Service

Re: Hosting - Azure App Service

by Leon Stringer -
Number of replies: 1
Picture of Core developers Picture of Particularly helpful Moodlers

Moodle insists it is accessed using $CFG->wwwroot. It enforces this by checking the request by inspecting $_SERVER[]. In a standard configuration the browser connects directly to the web server (assuming $CFG->wwwroot is "https://moodle.example.com"):

Browser's request
to web server
$_SERVER['HTTP_HOST']
that Moodle sees
GET https://moodle.example.com/ "moodle.example.com"

They match so Moodle is happy. But if the web server is behind a reverse proxy (e.g. load balancer):

Browser's request
to reverse proxy
Reverse proxy's request
to web server
$_SERVER['HTTP_HOST']
that Moodle sees
GET https://moodle.example.com/ GET https://webnode1.internal.test/ "webnode1.internal.test"

and you get "Incorrect access detected…" because $CFG->wwwroot and the $_SERVER[] values don't match.

Enabling $CFG->reverseproxy turns off this check. With this enabled you now cannot access the web server directly using $CFG->wwwroot, only via the reverse proxy. Direct access results in "Reverse proxy enabled, server can not be accessed directly".
Average of ratings: Useful (1)
In reply to Leon Stringer

Re: Hosting - Azure App Service

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Ahh..... ok. I've used load balancers for years but this has never come up. They've always passed through the request URL.

As you note, as long as it's not being used to cover up a misconfiguration of some sort.