New user with limited experience; HTTPS conversion resulting in inaccessible page? (Ubuntu)

New user with limited experience; HTTPS conversion resulting in inaccessible page? (Ubuntu)

by David Mortimer -
Number of replies: 12

Hi there!

A friend and I recently started working with Moodle, trying to set it up on an Ubuntu-based AWS server using this guide, and we succeeded in getting a test version of it up and running, which appeared to be stable; however, I have very little experience with network protocols (or network elements in general), and so when I tried to switch the Moodle setup to full HTTPS, the site became inaccessible. I can still access the default AWS's apache/ubuntu landing page, so I know that the ports for the server itself aren't an issue, it's just access to the website.

For the record, the site itself did its usual checks before actually converting to HTTPS and found no issues with anything, but it's just that I can no longer access the site; the ports on the AWS server itself are set to 80, 22 and 443 (I believe SSH, HTTP and HTTPS)--but I only set those because, again, I have very limited (if any) experience with network elements of websites and webservers, and those seemed to be the recommended settings, though they're all set to 0.0.0.0/0 and ::/0, allowing any incoming connections; I know I'll probably have to change this later, but it'd be nice to just have it running on HTTPS in general first.

I assume that I now need to edit some settings in an .ini file somewhere(?), but to be quite honest, I have no idea where to start, other than knowing that the Moodle installation is in the /opt/moodle directory.

I know this isn't a lot to go on, but both my friend and I would greatly appreciate if anyone has any advice or insight as to what I can do.

Average of ratings: -
In reply to David Mortimer

Re: New user with limited experience; HTTPS conversion resulting in inaccessible page? (Ubuntu)

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Did you change $CFG->wwwroot from 'http://..' to 'https://..' in moodle/config.php? See the full documentation https://docs.moodle.org/en/Transitioning_to_HTTPS.

Once that is in place you need to run the https://docs.moodle.org/en/Search_and_replace_tool.
In reply to Visvanath Ratnaweera

Re: New user with limited experience; HTTPS conversion resulting in inaccessible page? (Ubuntu)

by David Mortimer -
I did not, I must have missed that in the documentation as I was just using the "convert to HTTPS" function via the Moodle admin settings, I'll give it a try. Thank you.
In reply to Visvanath Ratnaweera

Re: New user with limited experience; HTTPS conversion resulting in inaccessible page? (Ubuntu)

by David Mortimer -

Because we don't actually have a domain name or host (beyond AWS) to redirect to or from set up at the moment, I've used the public IP of the server--however, I couldn't find a config.php, only a config-dist.php, is that still correct? I'm honestly not quite sure what I'm looking at, though I wanted to get confirmation that this is correct before I move onto the next step of search & replace.

I'm also unsure as to whether or not any of this helps with what I believed to be the switching of ports between the AWS server itself and those that allow access to the Moodle site? Because again, this is completely new to me and I have no real idea of what I'm working with, and want to try and understand it. I also don't quite get how the rewrite works if I'm just putting in an IP and don't know what ports I'm using for the site itself.

Attachment Untitled.png
In reply to David Mortimer

Re: New user with limited experience; HTTPS conversion resulting in inaccessible page? (Ubuntu)

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Sure you can run a Moodle site by its IP address - the URL you expect the site to react must go in to $CFG->wwwroot of config.php.

The second problem, Where is config.php? It is in the Moodle code directory, yes next to config-dist.php. Without one your site won't even start.
Average of ratings: Useful (1)
In reply to Visvanath Ratnaweera

Re: New user with limited experience; HTTPS conversion resulting in inaccessible page? (Ubuntu)

by David Mortimer -

Am I in the wrong folder, then? When I try to use sudo vi config.php, it creates a new file to edit, but I can't see config.php anywhere amongst those files or directories, and the site was definitely running and accessible by five of us in different locations before I used the PHP conversion tool on the Moodle admin page.

Attachment Untitled.png
In reply to David Mortimer

Re: New user with limited experience; HTTPS conversion resulting in inaccessible page? (Ubuntu)

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
You should know your platform! These are the generic instructions: https://docs.moodle.org/en/Installing_Moodle and Ubuntu specific: https://docs.moodle.org/en/Installation_on_Ubuntu_using_Git.
Average of ratings: Useful (1)
In reply to Visvanath Ratnaweera

Re: New user with limited experience; HTTPS conversion resulting in inaccessible page? (Ubuntu)

by David Mortimer -
I did preface by explaining I knew very little about what I was doing! Complete beginner at this mostly just following guides and researching as I go, but I'll check out those two links. I just don't find I get anywhere by just reading what they're saying, I need to know the exact details behind why X = Y, rather than just the fact that X = Y in most cases. I followed a guide to the letter, and you said that config.php *should be in that document* when it clearly isn't; do you not know why either? That seems to be the biggest issue here, and needs explaining, especially if I followed the guide linked in the initial post; Step-by-step Installation Guide for Ubuntu - MoodleDocs

I know I can *create* the .php, but you said it "should be there next to config-dist.php"

Is that done by default, or am I required to make it afterwards? If it does appear by default in most setups when following the Ubuntu guide, why did it not appear this time?

Thanks for the continued assistance.
In reply to Visvanath Ratnaweera

Re: New user with limited experience; HTTPS conversion resulting in inaccessible page? (Ubuntu)

by David Mortimer -
You were correct, there was a config.php, I was just in the wrong directory; the /opt branch directory rather than the public /var/www, so thanks for that.
In reply to David Mortimer

Re: New user with limited experience; HTTPS conversion resulting in inaccessible page? (Ubuntu)

by Ken Task -
Picture of Particularly helpful Moodlers

Pardon intrusion ... spotted some things ...

If site was ever working and viewable from outside Amazon's private network, you could have multiple moodle code directories.

172.31.34.119 seen in your terminal prompt is a private IP.
Cannot use that in config.php as folks outside that private network
can see/use that IP.

Anyhoo, from that same area, type: pwd (present working directory)
That will show your location ... path to the directory you are in.

Mr. V is right ... there should be a config.php file if the site was ever working.

See you are using sudo ... after logging on, thy this:

sudo -s

You should be prompted for your password again.  If you are a member of
sudoers, the prompt will change to one that shows root and provide a warning.  Do heed what it says.

For your purpose, we've done su to root in order to use a command to find a file on the entire system ... file config.php

Command: find / -name config.php

If found, it will show a path to that file.

If you see multiple finds, change into those directories and see if you can ls config.php.

To exit sudo root, type: exit

and to logout of login account: exit again.

'SoS', Ken

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

Re: New user with limited experience; HTTPS conversion resulting in inaccessible page? (Ubuntu)

by David Mortimer -
That did it, thank you. I didn't get a password prompt, but the search function did list numerous config.phps across multiple directories, but what I assume to be the main one was found in /var/www/html/moodle/config.php, so I'll continue from there. Thanks again.

Oh, and no worries; I wasn't using the private IP listed in the terminal; I was using the public IP that gets assigned by the AWS separately (offscreen). Thanks for the warning, though.
In reply to David Mortimer

Re: New user with limited experience; HTTPS conversion resulting in inaccessible page? (Ubuntu)

by David Mortimer -
Still no luck after having edited it, unfortunately. I'm assuming it now has something to do with the replace function? Or am I required to have an SSL certificate before it will show up on an HTTPS connection?
In reply to David Mortimer

Re: New user with limited experience; HTTPS conversion resulting in inaccessible page? (Ubuntu)

by Ken Task -
Picture of Particularly helpful Moodlers

What is in config.php must match what's in DB for the moodle AND web service (assuming apache) must also respond to https:// (port 443) ... Cert should be a valid cert issued from a 'Certificate Authority' (CA) and not a self-signed cert.

Shared hosting provider cPanel's *might* have an app/icon for setting up Certs (SSL/TLS) for all domains set up by shared hosting package.

Plus, if you have a WordPress - code at web document root - and moodle not by another FQDN but in a /moodle/ directory under WP, WP .htaccess file rules would affect the moodle code as .htaccess rules are hierarchical ... affect all directories under them.

You can discover a lot using local machine and the curl command ... unless you have Windows workstation.   If so, could use terminal on server:

curl -I https://yourmoodleurl

and

curl -I http://yourmoodleurl

Notice the diff?  first one is https second is http.

Sent you a PM with a question ... please respond via PM.

'SoS', Ken