Using Moodle through NAT

Using Moodle through NAT

by Tariq Nabi -
Number of replies: 5

I have seen that the moodle pages are all linked via the IP address of the server they are running from. How can we access an apache server runnig on a private network, running moodle from the internet. I have configured NAT to translate the private server IP address(172.16....) to the Public IP address (212.85....)

when we try to access it from the internet the first page tries to load but then it tries to go to the private IP address (172.16.....) which ofcourse cannot work throught the internet.

I can give the server a direct public IP address but that is a last resort.

I am running NAT on Linux mandrake 9.1

Other website servers seem to work fine through this NAT.  

Average of ratings: -
In reply to Tariq Nabi

Re: Using Moodle through NAT

by Joan Codina Filba -
I got the same problem.
the solution is to edit the config.php and where it specifies the addres substitute the code by an if statetement, if the address of the client is from your intranet use the internal adress else use the external one:

if (ereg("^198\.162",$_SERVER['REMOTE_ADDR']))
{
$CFG->wwwroot = 'http://198.162.0.XXX/moodle'; //internal ip
}
else
{
$CFG->wwwroot = 'http://external_ip/moodle';
}

Hope this helps.
In reply to Joan Codina Filba

Re: Using Moodle through NAT

by Peter Jeans -
Thanx guru - we needed to fix this also....
In reply to Peter Jeans

Re: Using Moodle through NAT

by Ken Lomax -

Hi All

I had the same problem. My fix was to delete the specific part of the URL in the config file and just leave a relative pathe there. i.e ./moodle  (I am running LAMP using Fedora4). I am now able to access moodle correctly from both within the intranet and externally from the Internet.

Regards

Ken Lomax (a newbie to moodle)

In reply to Joan Codina Filba

Re: Using Moodle through NAT

by Martin Dyer -
Thanks for the code. Worked first time and a great help.  I had been pondering this problem for some time.