Multiple IP-based wwwroot

Multiple IP-based wwwroot

Marcello Missiroli -
回帖数:9

Hi everybody.


My school has a strange firewall configuration (of which i don't have access) and, as a result, accessing moodle with the classical URL

http://cornimoodle.no-ip.org/moodle

fails when ever accessed from the intranet some 50% of the times. Using the internal DNS hasn't solved the issue.


Now, I already had this issue in the past and I sort of remember I solved it by changing the config file along the following line

[IF client IP comes from the intranet]

$CFG->wwwname = "intranet.name.org"

[ELSE]

$CFG->wwwroot = "cornimoodle.no-ip.org"

 

I know it's not elegant, but it used to work. Now I completely forgot hot to examine the client IP, but I will find it out.

Is there a more elegant solution that might work in this context?

 

回复Marcello Missiroli

Re: Multiple IP-based wwwroot

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Hi Marcello

You wrote:
> My school has a strange firewall configuration (of which i don't have access) and,

My sympathies! Yes, firewall tarzans can make ones life miserable.
伤心

> as a result, accessing moodle with the classical URL
> http://cornimoodle.no-ip.org/moodle
> fails when ever accessed from the intranet some 50% of the times. Using the internal DNS hasn't solved the issue.

Do they habe two DNS servers in round robin, set up differently?

> Now, I already had this issue in the past and I sort of remember I solved it by changing the config file along the following line
>
> [IF client IP comes from the intranet]
> $CFG->wwwname = "intranet.name.org"
> [ELSE]
> $CFG->wwwroot = "cornimoodle.no-ip.org"
>
> I know it's not elegant, but it used to work.

Do you mean "$CFG->wwwroot = 'http://'.$_SERVER['HTTP_HOST'];" thing? That is a hack, read this thread before doing it: http://moodle.org/mod/forum/discuss.php?d=209136. There are others who are happy with it. Sorry, I have no first hand experience.

> Is there a more elegant solution that might work in this context?

The neat solution is: http://moodle.org/mod/forum/discuss.php?d=210190&parent=916906.
回复Visvanath Ratnaweera

Re: Multiple IP-based wwwroot

Marcello Missiroli -

Ha! It's as simple as that. Thank you for pointing to this solution... it might be a slight security risk, but hey, it's  schools, after all, not the CIA.


微笑

 

I'll try that tomorrow.

Thank you

回复Marcello Missiroli

Re: Multiple IP-based wwwroot

Marcello Missiroli -

Hmmm it didn't work. At least not fully: I get the page, but without any CSS. Hava I forgotten something important?

回复Marcello Missiroli

Re: Multiple IP-based wwwroot

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Hi Marcello

Sorry, it is not clear to me what you _did_! Did you set up split DNS in the LAN and always (from within and outside LAN) access the site using only one URL?

From my side there seem to nothing missing in http://cornimoodle.no-ip.org/moodle. Can you confirm that from the Internet? Is the problem still you get no CSS 50% of the time inside your LAN?

What do the firewall Tarzans say about this?
眨眼
回复Visvanath Ratnaweera

Re: Multiple IP-based wwwroot

Marcello Missiroli -

You see nothing wrong because I changed it back immediately!

I have an external DNS http://cornimoodle.no-ip.org/moodle, that points to a dynamic IP. And I have and internal DND that points to a private IP (192.168.1.5). NORMALLY in works, but occasionally, from the inside, when I call the URL, a access NOT my moodle server, but the firewall itself.

I changed the wwwroot with the trick above but it did't work .


Ahm and the Firewall Tarzans cannot communicate with humans at all 微笑

 

 

回复Marcello Missiroli

Re: Multiple IP-based wwwroot

Ken Task -
Particularly helpful Moodlers的头像

Does your entity run any other servers using no-ip.org?

If not, then the only way to avoid in-correct links to images or documents served by Moodle is to use one Fully Qualified Domain Name that resolves both externally AND internally.

One is in control with internal DNS and zones those internal DNS servers are configured with and serve out.  Internal DNS servers, as long as they only pass NON resolvable request to outside DNS servers could actually host zones whose domain names are not owned or registered to the entity.  Is that proper?  Well, no not really, but the only network that is affected is your own since your internal DNS server should NOT be directly accessible/NOT queried from the public (outside internet).

Using the above as ground work for the following suggestion:

In your internal DNS create a .no-ip.org domain.
Only host it has is the A record is cornimoodle.no-ip.org
It resolves to the 10. or 192. or whatever private IP address being used.

Moodle server config can now use:
cornimoodle.no-ip.org in it's config.

Make no difference now where a client is coming from …
from internal network … internal DNS servers resolve the name to a private IP.
from external network - external DNS servers resolve the name to the public IP.

'spirit of sharing', Ken

 

回复Ken Task

Re: Multiple IP-based wwwroot

al tobing -

I use Ken's suggestion.This is exactly how I set up my moodle to serve internet and intranet users. So I use only one FQDN, but got resolved by 2 different DNS servers. And all has been working smoothly since then. 

Some times a go I read Visvanath's posting about potential problem using 'hacking' approach ( I forgot when) since moodle stores wwwroot name somewhere in database.

回复Marcello Missiroli

Re: Multiple IP-based wwwroot

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Hi Marcello

You wrote:
> You see nothing wrong because I changed it back immediately!

_What_ did you change back?

This conversation reminds me of: http://moodle.org/mod/forum/discuss.php?d=201541#p879908
伤心

Don't change things back and forth! May be this explanation will help: http://moodle.org/mod/forum/discuss.php?d=210190&parent=917620. It is the same thing what Ken and I were saying, i..e _not_ to use the HTTP_HOST hack but to set the DNS properly, so that within and outside the LAN you call your site by the same URL.
回复Marcello Missiroli

Re: Multiple IP-based wwwroot

Raju Patel -

Hi Marcello Missiroli

Below Configuration i am using intranet and internet both place it is working fine may be this will help you:

<?php  /// Moodle Configuration File

unset($CFG);

$server_id="";
$server_id=$_SERVER["HTTP_HOST"];
$CFG = new stdClass();
$CFG->dbtype    = 'mysql';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = '****';
$CFG->dbuser    = 'root';
$CFG->dbpass    = '*******';
$CFG->dbpersist =  false;
$CFG->prefix    = 'mdl_';

$CFG->wwwroot   = 'http://'.$server_id.'/moodle';
$CFG->dirroot   = '/var/www/html/moodle';
$CFG->dataroot  = '/var/www/moodledata';

$CFG->admin     = 'admin';

$CFG->directorypermissions = 00777;  // try 02777 on a server in Safe Mode

$CFG->passwordsaltmain = 'MIqZP9jr>PFJIV6o&=cF~~N/C';

require_once("$CFG->dirroot/lib/setup.php");
// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.
?>
Regards,

Raju Patel