Multiple redirects

Multiple redirects

by Govind Gaundalkar -
Number of replies: 6

I have Moodle 3.9 running on AWS.

The webserver has a RDS database  with a read replica and all works fine.

I decided to scale the webservers using the elastic load balancers just for testing puposes.I created an image of the existing EC2 instance(webserver) and attached the application load balancer of AWS.Now there is this internet facing load balancer followed by the two webservers followed by the RDS Mysql instance with a read replica.

Both the webservers are in healthy state in two different AZ's.When I hit my load balancer DNS in the web browser,the landing page of moodle is reached.But when I click login ,then I get multiple redirects error on chrome and    this  error " Firefox has detected that the server is redirecting the request for this address in a way that will never complete" on firefox.

I am not using HTTPS or an security certificate.

When I stop one of the webservers everything works fine.

What else needs to be done.

Kindly advise.

Thanks..

Average of ratings: -
In reply to Govind Gaundalkar

Re: Multiple redirects

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

The two things that spring to mind are:

  1. You may need $CFG->reverseproxy enabling in config.php depending on the URL the web server sees in the HTTP request and the one in $CFG->wwwroot, these can differ in load balancer scenarios.
  2. What session backend is in use? With multiple web servers you need to ensure that it's something all nodes can use.
In reply to Leon Stringer

Re: Multiple redirects

by Govind Gaundalkar -

I enabled the reverseproxy setting ,but then it shows a message that reverse proxy enabled on site.Contact System Administrator.I dont even get the landing page.

The load balancer sees the HTTP traffic from the internet.It passes this on to the two webservers.

I did not understand your second question.


In reply to Govind Gaundalkar

Re: Multiple redirects

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Does the port in the URL in the browser match that in $CFG->wwwroot in config.php? Can you tell us what the URL looks like in $CFG->wwwroot and what URL is being entered in the browser? You don't have to give us the exact name, you can say "http://mysite.net/moodle" or "http://mysite.net:8080/moodle".

Re session handling: I'm fairly sure that with multiple web server nodes you need to make sure they all talk to the same session handling back end. The default session handler is the local filesystem which is fine for a single web server but with multiple web servers the nodes can't share file locking. Database sessions might help in testing although this isn't recommended for performance reasons, either Memcached or Redis is normally used. However this is from memory, I can't find any documentation to support this; hopefully someone will be able to either confirm or correct what I'm saying.

In reply to Leon Stringer

Re: Multiple redirects

by Govind Gaundalkar -

Hi,

Apologies for replying late.

I figured out the solution to the problem I posted earlier.I enabled sticky sessions and things started working.The config.php has wwwroot = http://load-balancer-dns.com .This was the url being entered in the browser.

But now I created a self signed security certificate for https.This certificate is applied for the load balancer.The sticky sessions option is enabled.Now I am back to facing the same problem of multiple redirects.

In the config.php file I now have the wwwroot = https://load -balancer-dns.com

Thanks

Govind