I get a 404 error when I try to make my Moodle site visible on the LAN

I get a 404 error when I try to make my Moodle site visible on the LAN

by Samuel McFalls -
Number of replies: 3

I installed Moodle 3.7.2 from here on Windows 10. This should be the "complete package" and that seemed to work on localhost. I'm brand new to setting up moodle, I'm trying to see if it'll work for my use case.

I'd like to make moodle accessible to other devices on the LAN, and then on the Internet to show to some other parties for review. After that, I'll look at doing a real installation on a Linux box.

I followed the instructions here. I have a static IP and confirmed that the IP is correct. I stopped the Moodle instance with the Stop exe and changed conf.php and httpd.conf to contain `$CFG->wwwroot   = http://'<IP>/moodle';` and `ServerName 192.168.1.117:80` respectively. I saved both files and restarted using the Start exe.

After restarting, whenever I access the site at http://<IP>/moodle from any device, including the server, I get a 404 error trying to load the page that look something like this.

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.

This suggests that the server is in fact running at the address I think it is, but something must be configured improperly. Can anyone help me figure out what I'm doing wrong?
Average of ratings: -
In reply to Samuel McFalls

Re: I get a 404 error when I try to make my Moodle site visible on the LAN

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators

No qualifications to talk Microsoft. Still my two cents believing this is more about networking. (If your instructions from the year 2003 was valid, this should holt too.)

As you already stated, your project has three stages:
1. Moodle on 'localhost'
2. Acces in the LAN
3. Opening to the Internet

Stage 1 is successful? If a browser running in same (Windows 10) computer accesses Moodle on http://localhost/moodle or http://127.0.0.1/moodle, it is. Check $CFG->wwwroot in moodle/config.php.

For stage 2 you change $CFG->wwwroot to 'http://private.ip/moodle', where private.ip is the IP your Windows 10 machine in the LAN, possibly 192.168.1.117 in your case. If another computer in the same LAN answers to http://private.ip/moodle, you were successful. Strictly speaking, you should now run the https://docs.moodle.org/en/Search_and_replace_tool to replace the old URL with the new one.

For stage 3, you need to change $CFG->wwwroot again, this time to 'http://public.ip/moodle, where public.ip is the "proper" IP address you got from your provider, your router might call it the WAN address. You need to configure your router to some kind of IP forwarding from the WAN IP to your Windows 10 LAN IP and NAT routing for the machine to reply to the calling IP. This is the tricky part. If you managed to give your WAN IP a domain name (in the DNS), you have to use that in $CFG->wwwroot to 'http://private.ip/moodle'. Once it works, the replace tool has to run again.

That said, there are other alternatives for test runs. MoodleCloud is free up to 50 users. My favourite is the MoodleBox https://moodlebox.net, a SD pre-installed with Moodle latest for Raspberry Pi 3 and 4.

In reply to Visvanath Ratnaweera

Re: I get a 404 error when I try to make my Moodle site visible on the LAN

by Samuel McFalls -
Thanks for the reply! I did some poking and I did get Moodle visible on the Internet, but only at the root address. If I try to specify /moodle, it produces the error in my original post. Any idea why that might be?

I'll definitely look at the MoodleBox. My eventual solution was planned to be on a Pi, that might just save me a lot of time.
In reply to Samuel McFalls

Re: I get a 404 error when I try to make my Moodle site visible on the LAN

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
You mean, you got Moodle working from the Internet at http://domain but want the URL to be http://domain/moodle? Then you need two things: One is a configuration parameter of the web server, which is called DocumentRoot in Apache,. It should point to the parent directory of your Moodle code directory, in Debian and derived systems it is /var/www/html. The other one is $CFG->webroot which we were discussing. It must be 'http://domain/moodle'.

The future platform: If you planned Raspberry Pi any way, MoodleBox is a turn-key solution.