Switching to SSL broke Moodle (request for advice/help)

Switching to SSL broke Moodle (request for advice/help)

by Jason Hollowell -
Number of replies: 7
Picture of Particularly helpful Moodlers

Dear all,

I have a peculiar situation with a Moodle site that was functioning without issue prior to transition to ssl (https). The details are as follows:

1. The Moodle version is the most recent stable version...downloaded via Git about a week ago.

2. Running on Ubuntu 20.04 but with Nginx instead of Apache. Note here, it was running fine prior to the SSL implementation so I don't think the problem is specifically related to Nginx (a bit more on this below).

3. I installed certificates (yes plural) via LetsEncrypt snap certbot. I've never run the process for multiple domains using one certificate so I thought/think that could possibly be the issue but...(actually one certificate for multiple domains)

4. Changed the address in config.php to use https 

Now, when I access my site, I get a broken front page with no theme, graphics, pictures etc. I can login with my admin account but navigating is next to impossible given the broken format.

A few notes:

a. I registered three domains with one LetsEncrypt certificate. The other two work without issue. One of the other two is a php web app (Limesurvey) that seems to be similar to Moodle (somewhat) in design (i.e. php script based).

b. LetsEncrypt modified my virtual server files in Nginx when the certificates were installed, thereby transitioning me to SSL. If none of the domains worked, I would be suspect of the virtual servers but...as the other two work without issue and Moodle is technically being accessed and served (albeit in a broken format), I feel like this must be a Moodle issue...possibly?

At the same time, I have a sneaking suspicion I may be overlooking something painfully simple...something I'm not immune to. 😬

Any advice will be very much appreciated.

Peace

Jason

Average of ratings: -
In reply to Jason Hollowell

Re: Switching to SSL broke Moodle (request for advice/help)

by Jason Hollowell -
Picture of Particularly helpful Moodlers
A quick follow up here. Since the site I am working with is brand new and has not been used yet, I thought I'd try resetting up Moodle via the following:

1. Delete (rename) config.php to trigger the install/setup process
2. Use a different data directory
3. Set up a new DB

It appeared that this was going to work...until the install/setup process finished and I was directed to the Administrator setup page...where I see the 'broken' formatting. sad Screen shot below. I guess the problem is persistent and cannot be fixed simply with a fresh install. Hmm....scratching my head.

Must have something to do with the Nginx SSL setup for the virtual server...but...why is my other app (Limesurvey) working without issue...

Jason
Attachment Screen Shot 2021-07-17 at 10.47.00.png
In reply to Jason Hollowell

Re: Switching to SSL broke Moodle (request for advice/help)

by Ken Task -
Picture of Particularly helpful Moodlers

Purge caches ... all of them ... including browser cache.

However, sometimes we can't see the forest because of the trees!

Make sure you do a DB SQL dump, then ...

Please see:
https://docs.moodle.org/311/en/Transitioning_to_HTTPS

OR

one could make a copy of that SQL dump, load it up with a text editor that has search and replace ... nano comes to mind.
Search for http://oldfqdn/ replace with https://newfqdn/

Include the full protocol in front and the trailing / at end on search and replace.

Then import the edited sql dump into new DB.

Edit config.php to point to new DB.

Ok, see you are trying fresh install now ... so that changes things ...

in admin/cli/ of code use php install.php [ENTER].  Takes nginx out of loop and you can then get the very import creation of initial admin user password in plain text. smile

In new environment, do you have all the php extensions installed?  Most recent new php extension is sodium.

php -i

php -m

from CLI

Also ... please ... you are becoming a moving target and I am old and slow! :|   Let's stick to one. ;)

https://techexpert.tips/moodle/moodle-installation-nginx/

'SoS', Ken


In reply to Ken Task

Re: Switching to SSL broke Moodle (request for advice/help)

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Ken,

Thanks a million for your support. I too am getting old and a bit slow...but still motivated. smile

Let's see, the fresh install didn't work so I reverted. I'm back to the 'old' site which is just a week or so old. Never done anything on it aside from create an admin account so it's 'virtually' fresh.

I have cleared all caches via restarting Nginx and restarting php-fpm. I think that should do it...right?

I haven't searched for all instances of http to switch to https...will do that here shortly.

Config.php is currently set with https

Gotta tend to something else briefly but will look for lingering instances of http here shortly with fingers crossed...although I suspect since the fresh install turned up with the same results, it's probably not that simple.

Regards

Jason
In reply to Jason Hollowell

Re: Switching to SSL broke Moodle (request for advice/help)

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Ken,

A quick update as I track this issue down. There are no lingering http instances...but...apparently my problem has nothing to do with https.

As I'm digging around and troubleshooting I tried the following.

Moved back to a non-ssl connection and made the appropriate changes to Nginx to serve the site on a local ip without SSL. Low and behold that resulted in the Moodle site being served with the same formatting problems. So, somewhere along the line I've screwed something up and mistakenly thought it was related to the SSL certificates I installed yesterday. I'll have to take three steps back and see if I can figure out what is going on.

At this point I'm starting to feel like it is definitely a Nginx issue...and although Limewire is a php program, there must be something different about it that is enabling it to be served without issue while Moodle is stumbling.

Regards

Jason
In reply to Jason Hollowell

Re: Switching to SSL broke Moodle (request for advice/help)

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Ken, all,

Just documenting my progress here. I'm happy to report that I figured out the problem and it was, in fact, not related to SSL at all. I guess my feeling that the site was running prior to installing the SSL certificate was wrong. I did have Apache running for a while so I suspect I'd visited the site under that environment and mistakenly thought I was serving it with Nginx.

At any rate, I needed to add the following location block to Nginx. This is from here -> https://docs.moodle.org/311/en/Nginx

location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

I'm happy to report that it's all good now. My site looks delightful and is ready for customization. smile

Happy Moodling wink

Jason
In reply to Jason Hollowell

Re: Switching to SSL broke Moodle (request for advice/help)

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Ok, well...a big step forward but still have some minor issues.

I have my site 98% functional but I'm noticing some odd issues with image serving. See attached screenshot below. This appears where little question marks would be (links to help files) and in all the images that appear in the text editor (atto). Screen shot is from atto.

I'm guessing this is also a Nginx issue...hopefully won't be too difficult to figure out. Will document my progress here. wink

Cheers

Jason

P.S. Odd that the H5P logo appears...hmm.
Attachment Screen Shot 2021-07-17 at 13.26.59.png
In reply to Jason Hollowell

Re: Switching to SSL broke Moodle (request for advice/help)

by Jason Hollowell -
Picture of Particularly helpful Moodlers
Ken,

Thanks again for your help. I'm just posting here to document the process. I managed to get everything working smile as explained here.

I added a line to my Nginx config file and also purged all caches from within Moodle. One of those two, or both?, managed to get things in order.

Thanks again for your help here.

Cheers

Jason