moodle can not be accessed over the internet

moodle can not be accessed over the internet

by moodle user -
Number of replies: 14

hie everyone

can someone please help.

my moodle server runs on linux red hat and its dedicated to running moodle only. i have configured my config.php file as correctly as i possibly can.

my server runs behind a cisco 515e Firewall and NAT equipment.

the problem is that i can access the moodle from inside( intranet ) but from outside; i can access the server itself using the public ip address as provided by the NAT, but can not run moodle. the first moodle web page is displayed but pictures are missing and all the links are not accessible meaning over the internet i can do anything on moodle.

what is the problem???

Average of ratings: -
In reply to moodle user

Re: moodle can not be accessed over the internet

by Chris Throup -
When you access the site from inside the network, what url appears in the browser address bar after you click on a link? Is it the domain name you would expect? Or does it become an IP address, or even localhost?
In reply to Chris Throup

Re: moodle can not be accessed over the internet

by moodle user -

the ip address appears. beside to access moodle im using the ip address which is something like http://10.10.x.x when im inside but when im outside i use the public ip address from the NAT..

In reply to moodle user

Re: moodle can not be accessed over the internet

by Chris Throup -

It seems likely that Moodle is creating links to images and other pages using the internal ip address, which is fine when you are in the network but useless from the outside world.

Chances are that when you installed Moodle it took a guess at the site's address and came up with the internal IP.

Have a look in the file config.php which should be in the root directory of your Moodle installation.

Somewhere in that file will be a line like:

$CFG->wwwroot = 'http://your IP address/moodle'

You need to change that to:

$CFG->wwwroot = 'http://your domain name/moodle'

Depending on how the NAT is set up, there is a chance that doing this will enable access from the outside world, but prevent you from accessing within the network. Easy enough to resolve if that happens, but let's cross that bridge when we come to it.

Chris

In reply to moodle user

Re: moodle can not be accessed over the internet

by Reeny George -
what is the problem???

Try changing
$CFG->wwwroot = "http://".$_SERVER["HTTP_HOST"]."/";
or
$CFG->wwwroot = "http://".$_SERVER["HTTP_HOST"]."/moodle";
In reply to Reeny George

Re: moodle can not be accessed over the internet

by moodle user -
i have already changed that line in the config.php file. i put something like http://10.10.X.X and this work well for the intranet but for the internet i can only see the intial moodle page whose links i cant open and there are no pictures available when the site is opened.
In reply to moodle user

Re: moodle can not be accessed over the internet

by Chris Throup -

I don't expect you to list the IP addresses here, so let's assume the ip address you use inside the network is 10.10.10.10, and the public ip address you use outside the network is 20.20.20.20.

I would guess you currently have:

$CFG->wwwroot = 'http://10.10.10.10/moodle'

whereas you should have:

$CFG->wwwroot = 'http://20.20.20.20/moodle'

Obviously use the real ip addresses.

In reply to Chris Throup

Re: moodle can not be accessed over the internet

by moodle user -

if i use the other ip address which is the public ip ( eg 210.210.x.x )address instead of the non -routable (private) ip address (in this case 10.10.x.x) i can not access the moodle from the intranet which would also be a problem. so the main problem is that i cant put the two addresses in the wwwroot line so what do i do. both address are obtained from our NAT.

In reply to moodle user

Re: moodle can not be accessed over the internet

by Chris Throup -

A little php jiggery-pokery is needed. Try:

$CFG->wwwroot = 'http://'.$_SERVER['SERVER_NAME'].'/moodle';

In reply to moodle user

Re: moodle can not be accessed over the internet

by John Isner -
You can have two addresses.
From "http://docs.moodle.org/en/masquerading"

Running Moodle Behind A Masquerading Firewall

You may be running Moodle behind a Masquerading Firewall (using Network Address Translation or NAT). In this case your internal Moodle server will most likely be assigned a non-routable (private) IP address in one of the following ranges:

Moodle can be set up using the standard instructions but will only be accessible within the local network. To make the Moodle server accessible from outside of the network you will need to address the following points:

  • Ideally provide a domain name for your external network.
  • In your firewall or router set up port forwarding to forward HTTP requests (port 80) to your Moodle server
  • Your moodle config.php will need to be modified so that $CFG->wwwroot is modified according to the IP address of the client.

Modify config.php by adding the following code snippet around your $CFG->wwwroot setting:

 $subnet = '192.168';
 $client_ip = $_SERVER['REMOTE_ADDR'];
 if (strpos($client_ip, $subnet)===0) {
 $CFG->wwwroot = '...internal URL...';
 }
 else {
 $CFG->wwwroot = '...external URL...';

 }
 // $CFG->wwwroot = .... // comment out the origninal setting

The $subnet variable is set to the most significant values of your internal IP addresses (most likely '192.168.' or '10.'). The 'internal' URL is the appropriate setting for access from the local network. The 'external' URL that for external access.

Limitations

Using this method you will be unable to add full URLs that refer to resources/activites/files etc. within the same Moodle site. That is, for example, making a link in a resource to an image in the course's file area will not work properly if the URL contains the domain part.



In reply to John Isner

Re: moodle can not be accessed over the internet

by moodle user -

This makes sense let me try it and will update you on the progress. thanks a lot guys...

In reply to John Isner

Re: moodle can not be accessed over the internet

by moodle user -

i have made the changes as highlighted in this suggestions. the good news that some of the links on the intial web page are now working much better. but when i try to log in  using the login link on that page , from outside im get the following error:

The request url /217.x.x.x./login/index.php was not found on this server

Apache /2.0.52(Red Hat) Server at 217.x.x.x port 80

217.x.x.x  represents the public ip address that we are using to browse the server from out side.

so what could it be this time?????

In reply to moodle user

Re: moodle can not be accessed over the internet

by T.C. Chappelear -

I also am interested in this problem.  I set up a server on a desktop running windows xp to use Moodle to facilitate a professional development site for some local teachers.  I started with the problem that you have now.  I could always access from the internet but not from the intranet.  This kind of defeats the purpose in my case because teachers could not access at school.  Anyway, once I get back from spring break I am going to get it going and I will let you know if I find an answer that works.  It seems to me that it should be easy for moodle to just have the two ip's (internal and external resolve to the same server)  Good luck and I will keep you informed with what happens with me.

Tcchap