access IP

access IP

by Kyle Brown -
Number of replies: 13
i haven't found a spot for this any where or found it in the fourm (not saying it isn't there) but i have set up a moodle server and we added it to a network that had another server on port 80. so we made the port 8880. we did have some router trouble, but we got it so you could access it from a remote location. the problem we are having is we can't use it on the interal network cause of the IP. this is without a paid domain. one thing that you could think about adding into the server code is the ability to have moodle accessed on 2 different IP's (example: the outside IP would be 68.146.35.78:8880 and then the internal network could access it on 192.168.1.2 or something). if there are not any problems in doing this, it might be something to consiter. or if someone has figured out how to get it internal and external using a Cisco 800 sreices router.
Average of ratings: -
In reply to Kyle Brown

Re: access IP

by koen roggemans -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Translators
How about a split brain DNS configuration? Have you tried that?
(point on the internet dns to 68.146.35.78 with www.yourserver.com and on your internal dns-server to 192.168.1.2 with www.yourserver.com)
In that case, the place where moodle resides is (and should be) the same from the moodle server side of view (www.yourserver.com/moodle). Moodle shouldn't be aware on what IP-adress it is.
I think the configuration with a different port doesn't matter, as long as you remember to add the 8880 to the URL. Don't forget to open your firewall for incomming connections on that port.
In reply to koen roggemans

Re: access IP

by Kyle Brown -
if you look at the config.php you get something like this:

unset($CFG);

$CFG->dbtype    = 'mysql';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'moodle';
$CFG->dbuser    = 'root';
$CFG->dbpass    = '';
$CFG->dbpersist =  false;
$CFG->prefix    = 'mdl_';

$CFG->wwwroot   = 'http://127.0.0.1';
$CFG->dirroot   = '/var/www/html';
$CFG->dataroot  = '/var/www/moodledata';
$CFG->admin     = 'admin';

What I am talking about is the wwwroot setting. if i set it to say what it is set now (127.0.0.1 or localhost) then i can't bring it up on another computer on the network or outside of the network. say the IP is 192.168.1.2 and i use a computer on 192.168.1.3 and point the web browser to 192.168.1.2. the resault is no images and the links don't go to the right place. that is what i have been talking about.
In reply to Kyle Brown

Re: access IP

by koen roggemans -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Translators
you realy should get yourself a proper fully qualified domainname smile. So much easier for humans smile.
You just can't switch IP-adresses in the moodle configuration alone. Also look at httpd.conf for the configuration of the servername of your (apache) webserver. For IIS on windows it's some searching and klicking sad
In reply to koen roggemans

Re: access IP

by Kyle Brown -
right now the problem is money. we are using a free one called no-ip.com. what do you mean by the apache httpd file? i know what it is but what would i change in there? i am using Fedora 4 (Red Hat Linux basicly) in server mode.
In reply to Kyle Brown

Re: access IP

by koen roggemans -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Translators
around line 280 in my httpd.conf- file (the one I use on my test machine, ...)

# ServerName allows you to set a host name which is sent back to clients for
# your server if it's different than the one the program would get (i.e., use
# "www" instead of the host's real name).
#
# Note: You cannot just invent host names and hope they work. The name you
# define here must be a valid DNS name for your host. If you don't understand
# this, ask your network administrator.
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address (e.g., http://123.45.67.89/)
# anyway, and this will make redirections work in a sensible way.
#
# 127.0.0.1 is the TCP/IP local loop-back address, often named localhost. Your
# machine always knows itself by this address. If you use Apache strictly for
# local testing and development, you may use 127.0.0.1 as the server name.
#
ServerName localhost
In reply to Kyle Brown

Re: access IP

by Dirk Herr-Hoyman -
Hmmm, seems like all the issues are at the TCP/IP level, not within Moodle.

A better approach to begin with would be to use "virtual hosting" on the port 80 of the server. You can have multiple DNS names point to the IP address, when the HTTP request comes in the HTTP server hands them off to the proper application. You can do this on many HTTP servers, certainly Apache and IIS can both do this. There is setup on these HTTP servers to make this work, all standard and well documented.

I think this might also address your public/private network issues, but there I'm a bit less sure having not tried this myself.
In reply to Kyle Brown

Re: access IP

by Juan David Martínez Pavony -

Hello Kyle.

I have a question from your words. Do you use 8880 in the URL, I mean, do you have to write down into the browser http://your.moodleserver.dom:8880

I want to have a Moodle installation in port 81 but without having explicitly write the port into the URL: http://my.moodleserver.dom

Does any body around here have it done?

Thank you very much.

P.D.

I have:

  • RedHat 4
  • Apache 2
  • MySQL 4.1.12
  • Moodle 1.5.3+
  • Apache serves other apps in port 80 with different IPs.

Dear helper: Do you need more related information?

Thank you very much.

In reply to Juan David Martínez Pavony

Re: access IP

by koen roggemans -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Translators
By default, a browser sends the request for a page to port 80 of an address, because it expects to find the webserver there listening on port 80 for a request.

When you let the webserver listen on another port, eg 8080, you have to tell the browser to knock on another port in order to find the webserver.
So I don't see a way how to change that. Somehow your request should arive on port 8080 to reach the webserver. The way to do that is typing the alternate port with a : after the IP-address or dns name of the server.

eg http://yourserver.com:8080/moodle or http://111.111.111.111:8080/moodle
In reply to Juan David Martínez Pavony

Re: access IP

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You can use Apache's mod_proxy and proxy-reverse your Moodle site.

Let's say you have your Moodle in an internal server 10.x.y.z, running at port 9876. You tell Moodle its $wwwroot is 'http://10.x.y.z:9876/. In your internet facing Apache, you use public address m.n.o.p, running at port 80. So you connect to 'http://m.n.o.p/' and you get your web pages.

Let's further suppose you want to publish your Moodle site with the following URL: 'http://m.n.o.p/moodle'. You have to add the following to your httpd.conf file (first, make sure you have mod_proxy and mod_rewrite loaded and enabled):
  RewriteEngine On
  RewriteRule ^/moodle$ /moodle/ [R]
  ProxyPass  /moodle http://10.x.y.z:9876/
  ProxyPassReverse /moodle http://10.x.y.z:9876/
Don't forget to restart your Apache daemon/service after the changes.

Saludos. Iñaki.
Average of ratings: Useful (1)
In reply to Iñaki Arenaza

Re: access IP

by Juan David Martínez Pavony -

Hello Iñaki.

I tried yesterday your recommendation, but I could not get it.

Do I have to put them into <VirtualHost> directive?

I have:

Listen 81

NameVirtualHost mymoodleIPaddress:81

<VirtualHost mymoodleIPaddress:81>

      ServerAdmin

      ServerName my.moodleserver.com

  .......

</VirtualHost>

Thank you very much. I really do not know to much about Apache and I can not understand Apache's online documentation about your Proxy and Rewrite modules.

In reply to Juan David Martínez Pavony

Re: access IP

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
No, don't put in inside your VirtualHost directive for mymoodleIPaddress:81, otherwise you won't get the benefit of if (everything that's specified inside a VirtualHost is only available once you've connected to the IP and port specicifed for that VirtualHost, which is precisely what you want to avoid).

Put it inside the VirtualHost directive for your moodleIPaddress and port 80.

Saludos. Iñaki.