Problems with registering to a specific hub

Problems with registering to a specific hub

by Michael McAuley -
Number of replies: 23

Hi

I wanted to tryout the community hub functions so setup a new site:
2.1.2+ (Build: 20111019)
and installed the hub module:
$plugin->version = 2011081200

I followed the instructions at
http://docs.moodle.org/20/en/Hub_administration
exactly and have double checked the settings for a private hub

I tried to register into this hub from another site I have & spent a few hours getting a 403 error .... Until I discovered that I had to leave the http:// off in the Private hub URL (slow I know ... I even updated the client site to 2.1.2+ (Build: 20111019) thinking this might help ).

But finally I got to the Registration information page filled it in clicked Register with and got a 404 error.

This may be human error but I'm not confident that it is because the URL it is looking for is


http://esl.[CilentSite].org/admin/registration/www.hub.[HubSite].com/moodle/local/hub/siteregistration.php ect.

which in fact doesn't exist.

If anyone could point me in a direction of what to try it would be much appreciated.

Sorry that my first post here is a request for help when it should be to point out how excellent Moodle is & how cool you all are!

Regards

Michael

Average of ratings: -
In reply to Michael McAuley

Re: Problems with registering to a specific hub

by Jérôme Mouneyrac -

Hi Michael,

you should be redirected to the hub in a adress like : http://MOODLEHUB/local/hub/siteregistration.php?...

You can put http://... as a private hub url, I always put http:// when I test it.

 

Note: to complete the registration, the hub will test if it can access your site. If it can't then no registration is possible.

In reply to Jérôme Mouneyrac

Re: Problems with registering to a specific hub

by Michael McAuley -

Hi Jerome

Firstly, many thanks for your reply.

And I agree completely I must be doing something silly or there must be something strange in my environment ... because i can see that it should be doing as you discribe .... but it is just not.

I was just hoping someone else might have made the same mistake & know the fix.

The problem has to be in the client as it's not geting far enough along for it to be a hub issue.... that will come later I guess.  The only thing I can think of at the moment is the redirect from the webroot to webroot/moodle.... But if that's it other people would have experienced the problem.

I'll setup a completly new client and try again....

Again many thanks.


Michael

 

In reply to Michael McAuley

Re: Problems with registering to a specific hub

by Michael McAuley -

 OK I’m absolutely not imagining this.

I downloaded a fresh copy of 2.1.2 and had no problems on the install (see environment pic)

Environ

I tried to register with the hub I setup but frankly no matter what I put in to the “Private Hub URL”  if it has http:// in front  I got the 403 error (see pics)

With Http

But if I left the http:// off I progressed to the registration information page (see pic).

reg

 

However, even then when I click on the “Register with.. “ button at the bottom I get a 404 error.

 

This seems, to me, to be a client side problem because I get the same sequence of events when I make up a hub host as when I try the one I setup.

I can’t see I have done anything wrong, because I haven’t done anything and the install passed all requirements.

So unless there is another setting or requirement that is not clearly documented I think this may be a real issue.

Regards

Michael

In reply to Michael McAuley

Re: Problems with registering to a specific hub

by Jérôme Mouneyrac -

 

I agree it's not a nice error.

I checked the code. In admin/registration/hubselector.php, it always redirects to admin/registration/register.php

Do not try removing http://. It should work with it. Your second issue is maybe related to your first, and at least we can go one issue at the time.

Is http://hub.test.com a real hub ?

In reply to Jérôme Mouneyrac

Re: Problems with registering to a specific hub

by Michael McAuley -
Hi

No hub.test.com is not real (I wish I had that domain)... I was just a bit sensitive about putting the real domain name on an open forum.  Still exactly the same thing happened when the real hub address was used ..... I'd be happy to private message you the address & admin access if it would help.

Both are new installs & besides a theme change & adding 1 db activity to the hub main menu block they are pristine.

I will keep trying the http:// but like i said when i do .... no matter what the hub domain i get the 403 error.

More information but .... I tried to register on the moodle hub rather than a specific hub & got to the captcha stage. So i'm thinking that narrows it down to either a hub problem or the handling/cleaning of the huburl variable in the registration.php form .... To narrow it down further can I ask at what stage in the registration process is the hub first contacted.... Is it before or after the registration information page?

If is before that would point to the hub being the problem .... If after it may be something to do with huburl handling in my install.

Thanks again
Michael
In reply to Michael McAuley

Re: Problems with registering to a specific hub

by Jérôme Mouneyrac -

in /admin/registration/hubselector.php, add error_log(print_r($CFG->wwwroot."/" . $CFG->admin . "/registration/register.php", true)); before:

redirect(new moodle_url($CFG->wwwroot."/" . $CFG->admin . "/registration/register.php",
$params));

 

in /admin/registration/register.php, add error_log(print_r('running register.php', true)); before:

 

admin_externalpage_setup('registrationindex');

 

If you see the first log in your server log file, and not the second one and still have the 403 error, I think it's your Apache config.

In reply to Jérôme Mouneyrac

Re: Problems with registering to a specific hub

by Michael McAuley -

Hi
I put in the error_log ‘ s as suggested and received:

a) When I put in Http:// into the
[26-Oct-2011 20:22:44] http://m21.[Domain].org/admin/registration/register.php

and get the 403 error
But

B) when I don’t include the Http:// I get:
[26-Oct-2011 20:24:51] http://m21.[Domain].org/admin/registration/register.php
[26-Oct-2011 20:24:51] running register.php

and get to the registraion information page.

Though still have the 404 error after clicking "Register with"

Further
c) When I attempt to register with moodle.org rather than trying to select a specific hub I get:
[26-Oct-2011 20:31:42] running register.php
[26-Oct-2011 20:31:49] running register.php

And am successfully redirected to the captcha page of hub.moodle.org

I’m going to try 2 experiments …..

Experiment 1:
    Using http://hub.moodle.org in the specific  hub registration process.
Results:
    When using the http:// I get the 403 error and the error log
    [26-Oct-2011 20:44:13] http://m21.[Domain].org/admin/registration/register.php

    When removing the http://   I get to the registration information page  however upon clicking “Register with “ I  get the 404 error and the error log:
    [26-Oct-2011 20:52:24] http://m21.[Domain].org/admin/registration/register.php
    [26-Oct-2011 20:52:25] running register.php
 
Theory:
     It’s not a problem with my hub as I get the same series of errors even using hub.moodle.org as the specific hub.

(Though this experiment suggest it is not the hub in truth I'm not 100% there might not be a problem there when I eventually get through because of the redirect I had in place. So I setup a completely new hub with no redirect so as to give the next experiment the best chance of succeding)

Experiment 2:
    Hijacking the variable HUB_MOODLEORGHUBURL replacing http://hub.moodle.org with http://h21.[Domain].org (new hub site I just setup)

Result:
   No problem getting to the registration information page. However when clicking "Register with...."

   I get a 403 error but this time at least I am getting it from the right place:

    http://h21.[Domain].com/local/hub/siteregistration.php?...................

    The error logs on the client suggests no problem:

      [26-Oct-2011 21:38:54] running register.php
      [26-Oct-2011 21:39:10] running register.php

Note:
    a) When I attempt to access http://h21.[Domain].com/local/hub/siteregistration.php without the variable value url=http%3A%2F%2Fm21.[Domain].org in the URL I simply get the "this hub cannot access your website error" rather than the 403 forbidden error

   b) I get the 403 forbidden error even if the permissions for /local/hub/siteregistration.php  on the hub are set to 777

Conclusion:
     Well I'm total confusion .... As the client and hub would have the same apache config .... I suspect all I am left with your suggestion of a "apache config problem"... However:

1) I am with a reasonably large hosting company (hostgator) & would think it would be a fairly standard install.

2) It must be a very specific problem as it can be removed client side by hijacking the HUB_MOODLEORGHUBURL variable ..... So the apache config problem must be triggered somewhere in the handling of the specific hub URL in /admin/registration/register.php and in /local/hub/siteregistration.php handeling of the client url (as it is removed when the url variable is removed).

3) I have a number of other moodle sites running on the same platform & haven't run into this type problem before which makes it even more confussing.

Unfortunatly for me an "apache config problem" doesn't narrow it down to something I can fix or test ..... Happily, it doesn't seem to be a problem any others have encountered .... still if anyone else wants to have a stab at developing a theory I'd be happy to test it as I'm out of ideas.

Thanks

Michael

In reply to Michael McAuley

Re: Problems with registering to a specific hub

by John Andrewartha -

Just a off the wall thought, you have enabled web services for you Moodle.   You do have xmlrpc on your moodle.   A hub and a registering server use xmlrpc to exchange the token used for authentication.   If my memory serves me.

In reply to John Andrewartha

Re: Problems with registering to a specific hub

by Michael McAuley -
Hi John

Thanks for the reply at the moment no idea is off the wall .... Web services & xmlrpc are enabled on the hub it is part of the setup instructions .... The client is at default setting so not enabled there .... I'll try enabling on the client tomorrow first thing.... Fingers crossed.

Another possibly off the wall theory (at the moment I'm stretching for ideas) that I would like to get Jerome's opinion on is that I am using php 5.3.8 and I discovered that in php 5.3.7 a bug was fixed in parse_url() where it incorrectly parses path when ? in fragment (see https://bugs.php.net/bug.php?id=54180 ). Now parse_url doesn't seem to appear in the hub or register scripts but it is in moodlelib .... Anyway my idea is that if you coded to compensate for the bug in User URL input handling might this be why my problem is happening.

If so it would explain the available facts.... Maybe too much of a stretch .... What do you think?

Regard & Thanks
Michael
In reply to Michael McAuley

Re: Problems with registering to a specific hub

by Jérôme Mouneyrac -

Ah it could be something buggy in the param maybe. Can you add:

error_log(print_r($params, true));

before the redirect(...);

Then tell us what the log is when you enter http:// and when you don't enter http://

In reply to Michael McAuley

Re: Problems with registering to a specific hub

by John Andrewartha -

The 404 error tells the tail.    File not found or not readable by the server.  AKA Permission denied.

 Check ownership and read permissions on the moodle/local/hub

In reply to John Andrewartha

Re: Problems with registering to a specific hub

by Michael McAuley -
All the permissions in the hub local/hub are 755 & all the permissions in the client admin/ registration are 644 .... Should they be different?

I didn't change them or anything.

Thanks

Michael
In reply to Michael McAuley

Re: Problems with registering to a specific hub

by Jérôme Mouneyrac -

As John said, maybe it's a permission issue. Try to chmod 777 the two files to see if it makes any differences.

In reply to Jérôme Mouneyrac

Re: Problems with registering to a specific hub

by Michael McAuley -

Hi

Ok so firstly thanks to Jerome and John for the suggestions.

Experiment :

Even though it’s not perfectly scientific I changed 2 conditions before running this test under the theory that if one of them worked I could always go backwards to find out which.

Condition 1: I Change all files and directories in the client admin/registration/ and the hub local/hub to 777

Condition 2: I turned on web services & activated XML-RPC on the client.

Note:  For additional information I also added  error_log(print_r($params, true)); before the redirect for both hubselector.php and register.php on the client.

Result:

a)      Using select a specific hub & HTTP://

403 error: Forbidden
You don't have permission to access /admin/registration/register.php on this server.

Error log:
[28-Oct-2011 02:08:20] http://m21.[Domain].org/admin/registration/register.php
[28-Oct-2011 02:08:20] Array
(
    [sesskey] => 2P1UmQbe2F
    [huburl] => http://h21.[Domain].org/
    [password] => 
    [hubname] => 
)

b)      Not using http://

I get to the registration information page ok but when clicking "Register With... "

404 error: Not Found

The requested URL /admin/registration/h21.[Domain].org/local/hub/siteregistration.php was not found on this server.

Error log:
[28-Oct-2011 02:11:26] http://m21.[Domain].org/admin/registration/register.php
[28-Oct-2011 02:11:26] Array
(
    [sesskey] => 2P1UmQbe2F
    [huburl] => h21.[Domain].org/
    [password] => 
    [hubname] => 
)
 
[28-Oct-2011 02:11:26] running register.php
[28-Oct-2011 02:11:35] running register.php
[28-Oct-2011 02:11:35] Array
(
    [huburl] => h21.[Domain].org
    [hubname] => 
    [password] => 
    [name] => Moodle 2.1 Sandbox
    [privacy] => notdisplayed
    [description] => test
    [language] => en
    [moodleversion] => 2011070102
    [moodlerelease] => 2.1.2+ (Build: 20111019)
    [address] => 
    [regioncode] => -
    [countrycode] => AU
    [geolocation] => 
    [contactname] => Admin User
    [contactphone] => 
    [contactemail] => michael@gmail.com
    [contactable] => 0
    [emailalert] => 0
    [imageurl] => 
    [courses] => 1
    [users] => 1
    [roleassignments] => 1
    [posts] => 1
    [questions] => 1
    [resources] => 1
    [participantnumberaverage] => 1
    [modulenumberaverage] => 1
    [submitbutton] => Register with h21.[Domain].org
    [token] => n0wFvNQoFol05MNzGKSVqJRAp49UMtQEm21.[Domain].org
    [url] => http://m21.[Domain].org
)

Conclusion:

I’m don’t know the system like you folks but I don’t see anything wrong with  those error logs. So my conclusion would have to be that I’m up the creak without a paddle. But the part that I really don’t understand is why is the redirect of the 404 looking for /admin/registration/h21.[Domain].org/local/hub/siteregistration.php on the client site.

I just don’t get it.

But great thanks for your ideas to test.

Regards

Michael

In reply to Michael McAuley

Re: Problems with registering to a specific hub

by John Andrewartha -

If it helps, you can try registering on my hub.  It's public and anyone can join.  For the moment.

The URL is   http://noodle.dorset.org.au:6080/moodle/

Let me know if you do.  I can look at both the Moodle logs and Apache logs.

We can then see a complete picture.

I know my hub works, I have several moodles registered on it.

John

In reply to John Andrewartha

Re: Problems with registering to a specific hub

by Michael McAuley -
Hi

Many many thanks for the kind offer John it is much appreciated. But at the moment my main problem seems to be selecting any selecting any hub through the select specific hub process.... Including hub.moodle.org .... If I can get passed this error however I might take you up on your offer to confirm I get client side right before dealing with manifestation of the same problem on the hub side.

Many thanks
Michael
In reply to Michael McAuley

Re: Problems with registering to a specific hub

by Michael McAuley -

Ok I think I have an answer:

After much testing …. Whenever a recognizable URL (ie a real protocol ftp://, http://, https:// and a string that could conceivably be a domain … so two letters with a dot in the middle eg x.x ) is included as the value of huburl in the call to admin/registration/register.php I get a 403 forbidden error.

It doesn’t matter that the URL is encoded with %3A%2F%2F replacing ://   I still get the 403 error.

This happens even when the value of huburl is manipulated directly in the browser URL bar …. So hubselector.php is never called and register.php is never reached … So absolutely not a moodle issue!

Sorry if I have wasted peoples time!!!

But other users may encounter this problem so I will report what I have discovered:

A google search for “http%3A%2F%2F 403 error “ (don’t you love google) showed that it happens all over the place ….

(eg: http://moodle.org/mod/forum/discuss.php?d=107067 )

It is caused by mod_security seeing the .php as an active attack

Supposedly, If your domain hosted server is using Apache version 1 then you can disable the mod security via .htaccess file

<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

But if your domain hosted server is using Apache version 2 than you can disable the mod security by using following code in servers main httpd.conf ..... According to http://wordpress.org/support/topic/403-error-with-press-this   the fix is to ask your hosting company to add an exception in the mod_security.conf of /conf.d

I Guess for a client in the moodle hub system this exception would be something like:

<LocationMatch "/admin/registration/register.php">
SecFilterInheritance Off
</LocationMatch>

For a hub I guess it would be

<LocationMatch "/local/hub/siteregistration.php">
SecFilterInheritance Off
</LocationMatch>

I haven’t gotten far enough along in the registration process to see if more calls are made with URL’s in the .php variables … Probably not, once client and hub know each other there would not be a need.

I did some testing on my .htaccess

<IfModule mod_security.c>
    SecFilterEngine Off
    SecFilterScanPOST Off
</IfModule>

Did nothing for me

<IfModule mod_security2.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

Gave me a 500 error which might mean I have Apache version 2

I’m going to continue to research this for a little before I contact my host, because I would like to see if I can possibly include the exception in .htaccess or access mod_security.conf through WHM or Cpanel myself … There will probably be a few of these exception and contacting the Host company for every one would be tedious…. If I find out more I’ll update.

Thanks again.

Regards

Michael

In reply to Michael McAuley

Re: Problems with registering to a specific hub

by Jérôme Mouneyrac -

Cool, I'm happy it's not a Moodle code issue.

Can you explain in short the issue/solution in this section: http://docs.moodle.org/20/en/Hub_administration#Minimal_Requirements. If I understood well it's actually a Moodle server issue and not a hub server issue, but I guess it will help to let hub admins know about this. Often they also manage the sites too.

Thanks Mike for your effort to find out about the real problem.

In reply to Michael McAuley

Re: Problems with registering to a specific hub

by Michael McAuley -
Hi

Me again... Just thought I would try the "register with moodle.org" process with the hijacked variable again to see the param values.

Got the 403 from the hub site again ... Expected .... More interestingly the param values are fine ... So it's the 403 that I get from hubselector that is my problem .... And it will be the same problem in the hub site for sure!.....The 404 is just an artifact of removing the http:// maybe

Also I just noticed the trailing slash that is in huburl param of hubselector.php on the client but not the param from register.php.... Though that's probably no a thing just removed closer to when it needs to be removed... More the http:// in hubselector redirect is the problem for me some how.



[28-Oct-2011 03:52:35] running register.php
[28-Oct-2011 03:52:41] running register.php
[28-Oct-2011 03:52:41] Array
(
    [huburl] => http://h21.[Domain].org
    [hubname] => Moodle.org
    [password] => 
    [name] => Moodle 2.1 Sandbox
    [privacy] => notdisplayed
    [description] => test
    [language] => en
    [moodleversion] => 2011070102
    [moodlerelease] => 2.1.2+ (Build: 20111019)
    [address] => 
    [regioncode] => -
    [countrycode] => AU
    [geolocation] => 
    [contactname] => Admin User
    [contactphone] => 
    [contactemail] => michael@gmail.com
    [contactable] => 0
    [emailalert] => 0
    [imageurl] => 
    [courses] => 1
    [users] => 1
    [roleassignments] => 1
    [posts] => 1
    [questions] => 1
    [resources] => 1
    [participantnumberaverage] => 1
    [modulenumberaverage] => 1
    [submitbutton] => Register with Moodle.org
    [token] => mnPJhkWpA7JusJzVutMnOEMeFUjy8azam21.[Domain].org
    [url] => http://m21.[Domain].org
)
In reply to Michael McAuley

Re: Problems with registering to a specific hub

by Jérôme Mouneyrac -

For any problems/improvements with Moodle code, can you write a tracker issue: https://tracker.moodle.org/secure/Dashboard.jspa

Thanks a lot smile

In reply to Jérôme Mouneyrac

Re: Problems with registering to a specific hub

by Michael McAuley -

Hi

I have updated: http://docs.moodle.org/20/en/Hub_administration#Minimal_Requirements as requested and added a improvement tracker https://tracker.moodle.org/browse/MDL-30060

Within the tracker I have added some hacked scripts that will allow registration from a client with mod_security to a hub with mod_security for your consideration.

This is both a hub and client problem.

Regards

Michael

 

In reply to Michael McAuley

Re: Problems with registering to a specific hub

by Ruth Hadikin -

Thank you for posting this thread Michael,

I have just installed moodle and got the error 403 msg upon trying to register - thanks to your efforts and you're generosity in sharing the information I was able to just get straight on to Hostgator who fixed the issue across the account...

according to their technician the mod_security rule is whitelisted for my entire account and I should not longer receive that error.

You have saved me hours of trawling through forums etc. trying to pin it down!in appreciation,

Ruth