Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Moataz Desouky -
Number of replies: 25

Hello, 

I am facing a problem when I try to access moodle from an external network (Internet), I installed moodle on Windows server 2012 R2, on a WAMP Apache server on the localhost, When I try to access it from the internet I face this error, "Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator." Every this is fine on the TMG roles, and I made a port forward on the routers, Every time I receive the redirect message, when I click redirect it tells me that, the page unavailable.


Please I need an urgent help in this.



Average of ratings: -
In reply to Moataz Desouky

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Olumuyiwa Taiwo -
Picture of Plugin developers

You need to change $CFG->wwwroot (in config.php) to match the external hostname/ip address and port you are accessing the site with from the external network.

In reply to Olumuyiwa Taiwo

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Moataz Desouky -

I already did so and this is my config.php, 

$CFG->wwwroot   = 'http://192.168.2.2:8181/moodle';

$CFG->dataroot  = 'C:\\wamp\\moodledata';

$CFG->admin     = 'admin';


I still have the same problem, it shows me the same message. sad


In reply to Moataz Desouky

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Olumuyiwa Taiwo -
Picture of Plugin developers

What are you typing into the address bar in the browser on the external computer you're trying to access your moodle site from? That's what you need to set $CFG->wwwroot to.

In reply to Olumuyiwa Taiwo

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Moataz Desouky -
what I type from the external network, is the real IP (Static IP), I change it in config.php also still gives me the same error. sad
In reply to Moataz Desouky

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Olumuyiwa Taiwo -
Picture of Plugin developers

That doesn't sound right. That error is produced if there is a mismatch between what you've typed into the browser address bar and the value of $CFG->wwwroot. 

Can you provide the following info:

* The value of $CFG->wwwroot in your config.php

* The external/static IP address (and port number if applicable) that you're typing into the browser address bar

* Your router port forwarding rules

In reply to Olumuyiwa Taiwo

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Moataz Desouky -

This is what I have in config.php and I changed the the Local IP to the Real IP I have, 


$CFG->wwwroot   = 'http://192.168.2.2:8181/moodle';

$CFG->dataroot  = 'C:\\wamp\\moodledata';

$CFG->admin     = 'admin';

changed to 

$CFG->wwwroot   = 'http://REAL IP:8181/moodle'; (Real IP) and the Port.

$CFG->dataroot  = 'C:\\wamp\\moodledata';

$CFG->admin     = 'admin';

 and this is the router configuration for the port forwarding.. but it shows the internal network interface for the TMG, I believe all the configuration on the TMG and the router is fine, because I reach the Apache Server from outside, but when I try to access the project (Moodle) on the apache I get the redirect page.



In reply to Moataz Desouky

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Olumuyiwa Taiwo -
Picture of Plugin developers

This is weird - you've set $CFG->wwwroot = http://REAL IP:8181/moodle in config.php, but when you type http://REAL IP:8181/moodle into the browser, you get an error saying the site can only be accessed through http://192.168.2.2:8181/moodle

I wonder where Moodle is getting the http://192.168.2.2:8181/moodle displayed in the error message from. The only thing I can think of is that the value of $CFG->wwwroot is cached, but I doubt that very much. On the off chance that it is, clearing Moodle's cache (not your browser's cache) may help. To clear caches, login/SSH into your server and run this command:

php <MoodleInstallDirectory>/admin/cli/purge_caches.php

See if that helps.

As Ken has mentioned, you're best off setting up a DNS record for your public IP address ('REAL IP') and changing $CFG->wwwroot to the associated FQDN. That will save you a lot of headaches.

One more thing: your router configuration shows that you're forwarding the router external IP (REAL IP) to 192.168.1.99, and not 192.168.2.2 as shown in your error message. Do you have Moodle installed on both hosts?

In reply to Moataz Desouky

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Ken Task -
Picture of Particularly helpful Moodlers

The only way to properly setup a private IP Moodle server to be accessed from the public internet is to use a fully qualified domain name (not Windows private/internal domain names) for the server in DNS - both the external DNS zones and internal DNS zones.

Then, in config.php use the FQDN rather than the 192.168.2.2 IP address.

'spirit of sharing', Ken

In reply to Ken Task

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Moataz Desouky -

I understand your point, but I mean is there anyway to access it from the external other than FQDN?

In reply to Moataz Desouky

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Ken Task -
Picture of Particularly helpful Moodlers

There was, at one time, a 'work-around' one could use in the config.php, but think folks eventually had to give up on it

How about you think about this ... let's say that users inside access the server by inside IP address.   User edits or adds a link to a file.   That link will contain the config.php files wwwroot variable ... such links are concatenated using wwwroot variable from config.php + whatever.   That's what gets entered in the database ... link is http(s):/privateIP/blah/blah.

User then goes outside the private network, accesses the Moodle by public IP address (if you used the work-around) and login.   They go to the link created when they were inside and click it.    Since the link contains a private IP address read from the DB, which  is **NON-routeable** on outside Internet, when they click, they'll get errors - cannot find/cannot access.

Even if you attempted to write a fancy re-write rule for your apache server, how does one write the re-write rule that covers both inside and outside?

If public IP -> go to private IP

If private -> go to private IP ... if that's the rule that's called a proxy in apache.

And, as we know, private IP's are  **NON-routeable**.

There is one way to avoid it all ... plugin your Moodle server outside the entities boundary firewall and configure the server with a public IP address.   You'd need an internal DMZ switch.

But then, that server will have to protect itself ... rely upon it's own firewall and not the private networks firewall.   Hmmmm isn't that 'cloud'?

** Easiest ... best way ** ... FQDN both inside and outside.

'spirit of sharing', Ken

In reply to Ken Task

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Ken Task -
Picture of Particularly helpful Moodlers

Replying to own post ... how sick is that? :\

One more reason to use FQDN ... it's probably a good idea to run any web service under https rather than http.   While one could use a self-generated certificate all browsers and devices will complain about that as the cert is not from a Certificate of Authority (CA).  One cannot acquire a valid cert from a CA using private IP addresses ... must use FQDN of the server when submitting a certificate request to a CA - ie, the server's hostname/domain must be found in public DNS.

While one could acquire a wildcard cert to supposedly get around that, it still makes using both private IP and public IP still a bad choice ... there would have to be a cert for the private IP and a cert for public IP, me thinks by the same host name/TLD.   Would a browser/device get confused about that?

Anyway ... additional 2 cents ...

'spirit of sharing', Ken

In reply to Ken Task

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Moataz Desouky -

Hello again 

I already made a FQDN pointing on the real IP with the host, I tried to change it in the config.php. but still I have the same error.. I am not really good at PHP... is there a way I can chat with you in private to arrange a time and maybe you can help me with?


Thanks in advance

In reply to Moataz Desouky

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Ken Task -
Picture of Particularly helpful Moodlers

*IF* you do have a FQDN for the box now, then this should be in config.php:

$CFG->wwwroot   = 'http://FQDN:8181/moodle';

So let's check, from the box that's acting as the server, use whatever you can to check DNS.  If it were linux, one could use 'dig' and the DNS server settings for the box would be in /etc/resolv.conf.

dig -x 192.168.2.2

That is a reverse DNS lookup and should respond with the *fully* qualified domain name ... which looks like:

host (dot) somenet (dot) net (or whatever).   It is, however, a FQDN that *can* be resolved outside the private network as well, so ... let's see.   What do you get for:

dig @8.8.8.8 [yourfqdnforserver]

The 8.8.8.8 DNS server is Googles and is used often for a public (outside your private LAN/WAN) testing DNS.

Also, check the config file for apache on server.   Port 8181 is an alternative port for normally port 80 (ie, web server).   Apache server must be told to listen on that port (rather than it's defaulted port 80).

IF you change the port in apache config, apache must be restarted.

Please ... no word doc attached.

Have to ask ... why are you using an alt port?   Why not use port 80?   Skype? or other could be shutdown.

'spirit of sharing', Ken

In reply to Ken Task

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Moataz Desouky -

OK This is what I got after I changed to,

$CFG->wwwroot   = 'http://moodle.gounanursing.org:8181/moodle';

I still receive this message if I try to access it internally or from an external network. sad

This makes me crazy!! Port 80 is taken by the IIS sad

In reply to Moataz Desouky

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Ken Task -
Picture of Particularly helpful Moodlers

HTTP_REVERSE_VIA     TMG
HTTP_HOST     hostobsecured.elgounanursing.local:8181
SERVER_ADDR     192.168.2.2
SERVER_PORT     8181
REMOTE_ADDR     192.168.2.1

Project is named moodle and points to http://moodle ... which won't work for sure, me thinks.

https://docs.moodle.org/30/en/Reverse_proxy_frontend

You also need to research shutting down (never to launch on reboot) IIS *OR* don't run apache.   Run IIS!

'spirit of sharing', Ken

In reply to Ken Task

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Moataz Desouky -

I really did not get that, if its possible can you send me some steps to follow, as you I run this Moodle on WAMP Apache server, on windows server 2012 R2, I am kinda lost here!!

In reply to Moataz Desouky

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Ken Task -
Picture of Particularly helpful Moodlers

First, am going to show some things in this response which some will baulk at, but ... if your private network is secure then it should make no difference.

The problem is an internal DNS issue - thus also affects how one sets config.php for Moodle.

http://moodle.gounanursing.org:8181
197.45.49.149

dc-01.elgounanursing.local - this is now exposed in the settings page one sees when accessing the site from the outside.

Can hit your site from external by FQDN.   Get some sort of
settings page ... can see php extensions enabled as well
as Tools, Projects (moodle is under that one), and Aliases:
phpmyadmin, phpsysinfo, sqlbuddy, webgrind.

None are accessible from the outside however.

Conclusion: an internal DNS issue.

The DNS server for your internal network which is a .local network
needs to have an entry that maps the private IP address
192.168.2.2 to the same FQDN as outside DNS would resolve to
the outside IP address 197.45.49.149.

So if one were on a Linux box internal to your network (the .local)
and they did a dig (DNS query) on the .local DNS server it would show:

dig moodle.gounanursing.org
moodle.gounanursing.org. 3600    IN    A    192.168.2.2

If you don't have an internal DNS server, then one has no choice
but to use hostfile entries in server as well as internal workstations
that are to access it.  (Google for that on how to do that in Windows)

A hostfile entry would look like:

192.168.2.2 moodle.gounanursing.org moodle

IF, that hostfile entry were on a laptop, and the laptop is taken outside the private
and connected to another private network, that hostfile entry
would have to be commented out.   That laptop would use the DNS setup of the network it's connected to
and lookup the host name moodle.gounanursing.org and find it's
public IP address 197.45.49.149 and thus be able to access.

The only sure way to get an internal Moodle server on .local to be
accessible to both internal (private) network and the outside internet
is to use DNS ... a fully qualfied domain name as it appears to the outside
internet ... ie, moodle.gounanursing.org

Then, in your config file, rather than IP address, you can use
the FQDN (moodle.gounanursing.org) inside/outside with no issues.

'spirit of sharing', Ken


In reply to Ken Task

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Moataz Desouky -

Hello again, 

I am sorry for the late reply! smile

I have created a DNS record on my internal DNS pointing to moodle.gounanursing.org "FQDN"

and I changed it in config.php.. The problem now it still giving me the same error message but this time the browser keeps loading and redirecting as if there is a loop!!

Any ideas why is that?


Thanks for your patience!! smile

 

In reply to Moataz Desouky

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Olumuyiwa Taiwo -
Picture of Plugin developers

Visiting the site at http://moodle.gounanursing.org:8181/moodle/ gives this error:

Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry.
Please notify server administrator.

Are you sure your DNS is pointing to the correct IP address and you've changed $CFG->wwwroot to http://moodle.gounanursing.org:8181/moodle/?


In reply to Olumuyiwa Taiwo

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Moataz Desouky -
The Host DNS pointing to the Real IP, and yes I have changed $CFG->wwwrootto http://moodle.gounanursing.org:8181/moodle/?, and it gives me the same error from the internal requests also, so I have to change it back, to be able to access it from the internal network sad sad
In reply to Moataz Desouky

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Usman Asar -
Picture of Plugin developers Picture of Testers

Rabnawaz,

First thing, if a dedicated IP is allocated to you, why do you need additional port?

Secondly, the internal IP is only understood by nodes on intranet, and not on internet, so you giving local IP in CFG file and expecting external browsers (outside of network) to understand the public class IP automatically is never going to happen, Unless you are connecting from external network using VPN service to your Uni's network.

Giving external IP in CFG file will may not work either unless your router/firewall has loop back functionality.

Have you setup Bindings properly?

In reply to Usman Asar

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Bryan Hou -

Hi Usman,


What is Bindings?  


I have set up loopback policy in my router/firewall and use external static IP  in my CFG wwwroot but fail both inside and outside of my campus network.


Thanks,

Bryan

In reply to Ken Task

Public IP and Private IP in moodle server accessing from outside

by raj singh -

Hi, 

I have installed my moodle in windows server 2012 with IP address 192.168.0.3 and local host url is campusmoodle.ng. Its working fine with WIFi and LAN. But if i want to access my local server outside i.e from my home with internet. How this could be done? Please provide me all necessary settings required. 

Raj  

In reply to Moataz Desouky

Re: Incorrect access detected, this server may be accessed only through "http://192.168.2.2:8181/moodle" address, sorry. Please notify server administrator.

by Marco Carrillo -

Este es un error de redireccionamiento, para solucionarlo tendremos que modificar el archivo "config.php", ubicado en la carpeta principal del moodle.


$CFG->wwwroot   = 'http://[direccion_ip_o_nombre_de_maquina]/moodle28';