Too many redirections

Too many redirections

by Camilo Esteban Garzón Casallas -
Number of replies: 7

Hi guys!

I installed moodle in a server with private IP (I didn't have the URL before). Now I have the URL, but when I change $CFG->wwwroot and try to enter to moodle there's a message "Too many redirections". Here's the thing:

Domain: https://www.mydomain.com

Moodle's URL: https://mydomain.com/moodle

The folder "moodle" (the red one) is a different server,  a proxy redirects from mydomain.com/moodle to LMS server. I tried to install moodle in a different dir, but when I go to https://mydomain.com/moodle/newdir it redirects to https://mydomain.com/newdir/install.php and show 404 error (obviously). I don't know why deletes moodle's folder from the URL.

I'm using moodle 3.7 with PHP 7.2.11.

Thanks a lot for your help.

Average of ratings: -
In reply to Camilo Esteban Garzón Casallas

Re: Too many redirections

by Ken Task -
Picture of Particularly helpful Moodlers

So why a new directory? .... old IT philosophy of 'if it works, don't fix it!'

If you have a FQDN for your Moodle now (and I assume a cert as well
so your site can run https://) all one needed to do was change config.php in the moodle from IP to FQDN.
Run search and replace tool in moodle search for IP replace with FQDN.

So what changes did you make to web service proxy setup (apache or nginx) and config.php?

Don't weave such tangled webs myself anymore, so consider response more 'food for thought'! smile

'SoS', Ken

In reply to Ken Task

Re: Too many redirections

by Camilo Esteban Garzón Casallas -

Hi Ken,

The new dir was a test, before that I got the error "Too many redirects". That happened when I changed the wwwroot value (config.php).

Let me explain again, moodle was installed in with a private IP, later I changed the IP for the URL "https://www.mydomain.com/moodle". At this moment the browser showed the error "Too many redirects".

I tried to fix it making changes in Apache (virtual host), with the htaccess file, deleting cache, but nothing worked. Then I try to install moodle into a different dir and I saw that the address changed. I mean, if I go to https://www.mydomain.com/moodle/newdir it changes to https://www.mydomain.com/newdir (it deletes moodle folder).

Basically, I want to publish moodle smile

Thanks a lot for your time!

PS: I can't access to moodle but I can see the login form (it's a custom PHP form) if I write the entire address to that file.

In reply to Camilo Esteban Garzón Casallas

Re: Too many redirections

by Ken Task -
Picture of Particularly helpful Moodlers

Am still confused ... first posting you showed two urls/domains ...

one for www.yoursite/

and one for yoursite/

So what's in config.php of the original moodle?

What's in the .htaccess - what it was original and what changes did you make?

Then there is this 'proxy' you mentioned ... in virtual apache?  Config for it or those?   Looks like?

You can turn on debugging via copying: // 7. SETTINGS FOR DEVELOPMENT SERVERS - not intended for production use!!! lines for debugging from config-dist.php and placing them in config.php.

Have you checked apache web service logs ... access + error?

Have you considered putting everything back (revert what changes you made to whatever file/config, etc.) ... back to where you can get the original error?

No offense, but sounds like a semi-panic attack and what things you've tried have only made things more confusing? :|

Mind PM'ing (private message) me the URL to your site?

'SoS', Ken


Average of ratings: Useful (1)
In reply to Ken Task

Re: Too many redirections

by Camilo Esteban Garzón Casallas -
Yes, I wrote 2 address, https://www.mydomain.com is the company's web site and https://www.mydomain.com/moodle is moodle's URL. Moodle is in a different sever. In config.php is https://www.mydomain.com/moodle. But it shows the error and there's no way to access to moodle.

The .htaccess was empty and I wrote this:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.mydomain.com/moodle [R=301,L]

But It didn't work, so I just let the file just how I found. 

I don't know anything about the proxy (sorry), I just know that exist and the IT guys redirected https://www.mydomain.com/moodle to moodle's server.

I can't turn debugging on because there's no way to enter moodle, even if I change the config file. That's what I get (the original error):
error

The error logs doesn't shows anything, but access shows this:
"GET / HTTP/1.1" 303 482 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15"

About the semi-panic attack maybe you're wright 😅 I've been working on that for a week and I tried solutions I found in the forums but nothing worked :'(

And sure, I'm gonna send to you the URL.

Thanks a lot!

By the way, sorry for my English!
In reply to Camilo Esteban Garzón Casallas

Re: Too many redirections

by Ken Task -
Picture of Particularly helpful Moodlers

Wow ... after poking and probing a little remotely (op shared true url to site) ... I'd say someone is 'extremely paranoid' about access to the server let alone moodle.

Additional security check is required

Why am I seeing this page?

The website you are visiting is protected and accelerated by Incapsula. Your computer may have been infected by malware and therefore flagged by the Incapsula network. Incapsula displays this page for you to verify that an actual human is the source of the traffic to this site, and not malicious software.
What should I do?

Just click the I'm not a robot checkbox to pass the security check. Incapsula will remember you and will not show this page again. We recommend you run a virus and malware scan on your computer to remove any infection.


After passing I am not a robot ... am able to get your redirect error ..

The .htaccess was empty and I wrote this

Moodle code doesn't come with an htaccess file.  Yours does have a redirect.

Suggest renaming to htaccess.txt
mv .htaccess htaccess.txt

and let's remove that htaccess issue.  Redirects might already be in place with main nginx config to force any traffic to https:// (port 443).

< X-Powered-By: PHP/7.2.11
Server: nginx/1.12.1

Access to https://yoursite/yourmoodledir/local/ one can see a directory listing of contents and the 2 readme's in there.

Check your nginx server access logs and you should see my 'robot passed' IP address and OS/Browser.

If I access https://yoursite/yourmoodle/xxx server does kick out a 404 ... not found page ... valid.

At this point, think you need to have a talk and assistance from your server/network techs.   Your moodle 3.6 isn't that insecure:

Bug fixes for general core bugs in 3.6.x ended 11 November 2019 (12 months).
Bug fixes for security issues in 3.6.x will end 11 May 2020 (18 months).

It ain't May yet!

'SoS', Ken



In reply to Camilo Esteban Garzón Casallas

Re: Too many redirections

by Ken Task -
Picture of Particularly helpful Moodlers

Follow up and more info ...

In your cert for server ...

Digicert cert
Render Moodle: Quirks mode ... I haven't seen that since very old Internet Explorer (which even M$ doesn't want anyone to use) and a
very old Joomla!!!!!  Am using neither right now!

Cookies come only from main site.   Not full disclosure here but ... using curl -I test of main site and moodle directory ....

Set-Cookie: visid_incap

GMT; HttpOnly; path=/; Domain=top level domain ... no subdomain.

Your moodle setting for cookies are?

The error one sees:

"This problem can sometimes be caused by disabling or refusing to accept cookies."

Moodle can't set cookie.

Also:

* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol

X-CDN: Incapsula

X-CDN is content delivery network ...  a cache.  Meant to speed up access to sites by caching and serving out from that cache so clients don't have to access Moodle cache.   Moodle has caching of it's own - due to the nature of Moodle being dynamic ... changes often ... might Incapsula's CDN hurt rather than help?

'SoS', Ken