Cloudflare Tunnel + Apache + Moodle

128 Views Asked by At

I'm trying to install Moodle 4.2 stable on my Ubuntu 22.04. Since I don't have a public IP, I hope using tunnel so that others can visit the website.

Please help, thanks. Tell me if any other information should I provide.

What I want:

Visit https://moodle.mydomain.com would go to the Moodle I set.

What I did:

  • I put moodle directory in /var/www/html/moodle
  • In cloudflare tunnel I set "https://moodle.mydomain.com" to "HTTP://localhost"
  • In apache configure virtual host 80, document root is /var/www/html/moodle
  • In moodle/config.php wwwroot = 'https://moodle.mydomain.com'

What happended: When I visited https://moodle.mydomain.com it showed blank page with nothing.

What did I tried:

  • I changed moodle/config.php wwwroot = 'http://localhost' and visit it in my ubuntu VM, it works.
  • However this way if I use https://moodle.mydomain.com it would redirect to http://localhost

So I think the moodle setting is fine. And I continued other trail ended up failure.

Other information

  • The tunnel is working fine since I've used it in the same machine for other webapp using port 8000.

Update I think I need some method to tell moodle use relative url root instead of using absolute one. Like if one access via 127.0.0.1 then the url would be 127.0.0.1/... while one acceess via https://... then the url would be https://.../...

The config.php seems restrict it to use only value that I've set so it goes https://moodle.mydomain.com all the way.

So https://moodle.mydomain.com goes to 127.0.0.1 and it goes to https://moodle.mydomain.com thus infinite redirect.

Any method to solve it?

0

There are 0 best solutions below