WAN and/or LAN access to moodle 2.6+

WAN and/or LAN access to moodle 2.6+

by kevin ho -
Number of replies: 15

With the help in this forum, I have successfully installed  moodle 2.6+. The only issue left is the access problem.

At the beginning, I can access moodle locally (intranet) by typing the LAN IP address in the browser ( such as  127.0.0.11/moodle, which is the fixed/appointed IP address for the host computer ) but can not access it from internet (outside). After changing the line "$CFG->wwwroot = 'http://127.0.0.11/moodle' ;" to "$CFG->wwwroot = http://48.60.230.167/moodle' ;"  in config.php (which is the fixed IP address offered by ISP), it can be access through internet but not from intranet any more.

I believe it should be able to access from both intranet and internet but have no idea of how to do it.

Some one can help ?  Thanks !

Average of ratings: -
In reply to kevin ho

Re: WAN and/or LAN access to moodle 2.6+

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Well... you will never be able to do this with IP addresses because, as you have discovered, your internal and external addresses are different. Moodle will not permit multiple wwwroot settings. 

So... you need to assign a hostname in DNS for your Moodle site. This needs to be configured to resolve to the internal IP on your intranet and to the external IP from outside. This isn't the only way to do it and some will argue that it has security implications. Start with this info - Masquerading

However, you need to discuss this fully with whoever controls your network and DNS.

PS.. 127.0.0.11 seems very odd for an internal IP! The 127.x.y.z addresses are for internal use (to their host) only and would not normally be used to build a LAN. So, this doesn't sound even like an intranet IP. 

Average of ratings: Useful (1)
In reply to Howard Miller

Re: WAN and/or LAN access to moodle 2.6+

by kevin ho -

Thanks, Howard

I got a DNS hostname from dyndns and replace the ip address with it in wwwroot setting.

I test it from internet (outside) its works but it still no working in the intranet.

When I log in  from intranet and type the dns hostname (without "/moodle"). it direct to my router's log in window. If I log in with "/moodle" then it shows: "404 not found, the requested URL '/moodle' was not found on this server'. ( it seems the log in request didn't go through the router to the host computer.)

Is there anything I can do to solve the problem?

PS.. you are right, 127.0.0.11 was a typing error, it is from the original localhost log in address "127.0.0.1".  Actually, the intranet ip is 10.1.1.11

In reply to kevin ho

Re: WAN and/or LAN access to moodle 2.6+

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Did you actually read what I wrote above and/or look at Masquerading?  You can't fix this with dyndns wink

In reply to Howard Miller

Re: WAN and/or LAN access to moodle 2.6+

by kevin ho -

Hi, Howard:

I am a Mandarin teacher and intend to establish my own moodle site in my home for students.  So, I am the only one to managing all the things for the site and it really hard/take times for me to pickup the knowledge of network.

 In the "Masquerading", it says "first get real DNS hostname " so I got one from dyndns.com.

"Then tweak internal DNS server" it said then, but I have no idea how to do it. 

After reading  your second message, I try to search "tweak internal DNS server" in the forums and it has nearly 30 discussions. I paste one below please check is it the right way to solve my problem? (Actually, it mentioned that is also from you.) If yes, then I will follow it to edit my config.php. (i.e. tweak internal DNS server ? )

There are two things I need to confirm with you. First, why its not the full IP address in $foo but only first two octets?  secondly, "bar.org" represent the full DNS hostname, right?

 

Thanks for your patients!

 

To add to Alan's post, there are several ways of doing this, but the most elegant and more manageable is to use DNS. Try this:

  • On your internal DNS server, add an address record to map "foo" to the internal IP address of the moodle server.
  • Do the same on your external DNS server, so that the public sees "bar.org" mapped to the external publically accessible IP address.
  • You may need to use a firewall rule to NAT the internal to external addresses.

To get the $CFG->wwwroot variable to change depending on who is accessing, you'll have to tweak it by pasting the following into config.php file (from the old masquerading trick by Howard Miller):

$foo = '192.168';
$client_ip = $_SERVER['REMOTE_ADDR'];
if (strpos($client_ip,$foo)===0) {
 $CFG->wwwroot = 'http://foo';
} else {
 $CFG->wwwroot = 'http://bar.org';
//$CFG->wwwroot = 'http://... previous entry';

I'm assuming that 192.168 are the first two octets of your internal IP address. Note that you *must* use a firewall to protect your servers from forgery of REMOTE_ADDR, so discuss the pros and cons of this method internally with your security team. 

 

 

In reply to kevin ho

Re: WAN and/or LAN access to moodle 2.6+

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

If it's in your home, why do you need internal LAN access. Is this actually just so that you can access it?

Do you have a static IP address (for external access) or does it change? What operating system is your computer. Chances are, that all you need to do is to put the hostname in your 'hosts' file and you are done. 

Don't use this old method you dug up from years and years ago. 

Basically (with it set up to work externally), find and edit your hosts file and enter...

host.domain.something    127.0.0.1

Where 'host.domain.something' is the same hostname you put in dyndns. So, when you use that hostname on your local machine the hostname maps it to 127.0.0.1 and Moodle stays happy. 

In reply to Howard Miller

Re: WAN and/or LAN access to moodle 2.6+

by kevin ho -

Howard:

Yes, internal LAN access is only for myself which I use it to edit my moodle courses.

I have static IP from My ISP and I am install moodle in the computer with WindowsXP sp3 now.

I am testing all of it in my old computer but if it works I will buy a  Window8 desktop as my host computer for the new web site. 

I don't understand your last two paragraph, did you mean that I can access internally by key in "host.domain.something/moodle    127.0.0.1" (or without "/moodle") in my browser?

 I have try it in my browser but it not works. Or, this line need to put into my config.php to make the hostname maps to 127.0.0.1 ?

 

In reply to kevin ho

Re: WAN and/or LAN access to moodle 2.6+

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Ok...

1. Have it working with dyndns, the hostname you presumably bought, the hostname in config.php. That is it is working externally but probably not internally

2. Read this - http://kb.simplywebhosting.com/idx/0/045/article/

3. Whatever you put in config.php for $CFG->wwwroot, the 'hostname' is the bit between http:// and the next /. 

4. Add that hostname to your hosts file (see point 2) using 127.0.0.1 as the IP.

The result of all this is the dyndns resolves the hostname to your fixed IP address for external users. Internally (i.e. on your own machine) the hosts file resolves the same hostname to a different IP - 127.0.0.1. The hosts file takes 'wins' over the DNS resolution.

Does this help?

 

Of course - this is all a very bad idea. You would save yourself a lot of trouble buy getting some proper hosting. Neither XP or Windows 8 are designed to run server systems properly and securely.

Average of ratings: Useful (2)
In reply to Howard Miller

Re: WAN and/or LAN access to moodle 2.6+

by kevin ho -

Howard:

Its works!!!

Before the X'mas, I already install the moodle successfully but can only access it from intranet(i.e. from 127.0.0.1) .  After couple days study in the new year holiday (including search the solution from web site) , I can access it from internet.  Now, I can also edit it from intranet and remain the internet connection for my students at the same time. Its just like a new year present for me. Thanks a lot, Howard, without your help I can't make it.

There are two slight different when I set the host file :

First, instead of "127.0.0.1", I use "10.1.1.11" which is the assigned IP address by the router to host computer.

Second, the  sequence is opposite.  The IP "10.1.1.11" is in front and the dns host name at rear.

Although you  might think that I am greedy, but still I have to ask further help from you because I really need those functions.

1. When we put some file in the moodle , normally we have to upload it. Can I just copy it to the folder where it uploading?

2. Some times many courses will share one general file, can I set a hyperlink to it instead of upload again and again (and to different/duplicate folder)?

3. Can I plugin the font of Chinese character?

If moodle can support those functions, please provide the web-link instruction to me and I will learn and set it by myself. If moodle do not support, just let me know, then I don't need to waste the time to search it.

Thanks again!

 

In reply to kevin ho

Re: WAN and/or LAN access to moodle 2.6+

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

1. You need to configure a repository to allow this... see File_system_repository

2. I think there are some plugins to allow this but in standard Moodle, no. The file security system does not allow this. 

3. Moodle is fully Unicode. As long as you have the correct fonts on your client machines you should be fine. 

In reply to Howard Miller

Re: WAN and/or LAN access to moodle 2.6+

by kevin ho -

Your last post mentioned that its not a good idea to running moodle on winXP/win8 like mine.

I quite agree about it, But considering the cost and managing abilities, its the best way I can do by myself for a free access web site at the moment.

Thanks for your help and your concern.  I am really appreciate.

 

In reply to kevin ho

Re: WAN and/or LAN access to moodle 2.6+

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

True - but please don't be surprised (or blame Moodle) when it all falls over with a handful of users on the system. Your operating system was never designed or optimised for server use. 

In reply to Howard Miller

Re: WAN and/or LAN access to moodle 2.6+

by kevin ho -

Hi, Howard:

I think I need your further help. I am now install moodle to my new windows8 computer.

The installation of xampp is all right now.(at the beginning its not steable and shows can not find "icuuc49.dll" when I press the button to start Apache and MySQL, but after re-config the windows system it ok now.)

The problem is when I install moodle, it shows "Error: Database connection failed" at the page of "Database settings" which the picture of screen is attached.

How can I do to solve it?

Thanks

Kevin

Attachment setting.png
In reply to kevin ho

Re: WAN and/or LAN access to moodle 2.6+

by Jon Witts -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

That error message indicates that your Database user name and / or password is incorrect... Are you sure they are entered correctly?

Jon

In reply to Jon Witts

Re: WAN and/or LAN access to moodle 2.6+

by kevin ho -

hi, Jon

I key in the wrong user name and password.

Its ok now

thanks

In reply to kevin ho

Re: WAN and/or LAN access to moodle 2.6+

by kevin ho -

Hi, 

so i'm having some problems with adding new users. i've set up email self registration, and i've authorised them to join. in theory, they are suppose to receive an email with a link to confirm the new account right? now here is the problem, i have had 2 people create a new account via email self registration, but they have both said they have not received any emails either in their inbox or their junk/spam folders. additionally, i have tried to add new user account manually, but all three "new accounts" are still coming up as "potential user" and not allowing them to log in. 

is there something in the settings that i've missed that needs to be adjusted? or can you help me solve this issue?

 

Thanks