After trying and searching a lot about this problem, I couldn't find a solution, so I hope that you can help me. I installed Moodle 3.4 version on my Raspberry Pi with your tutorial:
In my configuration, I have a reverse proxy pointing to my ip, 192.168.25.222 with the Domain moodle.example.com, so the first thing that I tried was changing the config.php file, and setting wwwroot to 'http://moodle.example.com' , but this turns into a loop, because moodle points into the URL, and the domain points into the raspberry, so its unreachable. It works using the private IP as wwwroot 192.168.25.222, in the local network.
After searching for the problem, I tried changing wwwroot to 'http://'.$SERVER[SERVER_NAME']; but accesing from a external connection, you reach to the page, but you cant see any css, because it its trying to get it from the private ip and not from the domain. And if you access from the local network, you get:
Access to Font at 'http://192.168.25.222/theme/font.php/boost/core/1513761554/fontawesome-webfont.woff2?v=4.7.0' from origin 'http://moodle.example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://moodle.example.com' is therefore not allowed access.
I don't know how to fix it and I hope you can help me!