Nethserver Moodle from Wiki

Hi @mrmarkuz (any other, of course)

I am running Moodle module form wiki quite a long time, however now I want to make it work seriously :slight_smile:

I have four + 1 questions (maybe I already asked, but I do not remember):

  1. My site is reachable from external via hostname (www.my-domain.tld). The host name is set via

    config setprop moodle host www.my-domain.tld
    signal-event nethserver-moodle-update

    Can I add more host-names to reach moodle directly (e.g. www.other-domain.other-tld)

  2. Currently I defined list of virtual hosts covering lots of host names, e.g.

    my-domain.tld
    www.my-doamin.tld
    other-domain.other-tld
    www.other-domain.other-tld

    What I observe is when calling e.g. other-domain.other-tld, the browser is redirected to www.my-domain.tld (ad defined in question 1 using setprop host). Can I make work the website worke under each host name?

  3. the web-root directory from virtual hosts is:

/var/lib/nethserver/vhost/moodle4gmp/
I do not know how this is set. I do not remember how I have done this. Can i alter this somehow?

  1. Using [www.]my-domain.tld (or anyother hostname) ends up on nethserver default domain (aka the standard nethserver landing page) I do have to use [www.]my-domain.tld**/moodle**

    config show moodle
    moodle=configuration

    access=public
    apacheConf=alias
    host=www.gmp-kurs.online
    path=moodle

    I tried to delete the path name (e.g. by config setprop moodle path “”) but it does not work. Is it somehow possible to make moode work / install it directly in the web root?

Final question (edit): I can not reach any of the sites from within my network, I do not have any problems from outside (internet). Redirecting, Port forward seems to work on the internet - but why are the DNS not set correctly internally?

Thank you
Thorsten

NethServer Version: 7.9.2009
Module: Moodle / Wiki

1 Like

Please have a look here:

It looks like you can create your own vhost file with the right directory.

1 Like

I’m going to implement a vhost db prop to have moodle reachable under vhost.domain.tld without the “/moodle” path.
Another point is the Moodle wwwroot that’s set in /usr/share/moodle/config.php.
We could change it to

$CFG->wwwroot = 'https://'.$_SERVER["HTTP_HOST"].'/moodle';

so Moodle uses the hostname/IP that’s entered in the browser.

I guess you set it in the old server manager.
I recommend to move away the vhost data, delete the old one, recreate it in cockpit and move the data back.

Sorry, I don’t get it. What’s not correct, what do you expect?

Maybe you need to enable hairpin nat in the firewall settings to reflect the port forwards internally?

2 Likes

You are right, this is from the old server manager! Do I need to uninstall moodle completely? Or is it just OK to delete the old vhost? If so, I would need to set up a new vhost - How do I do that? Is it done via cockpit and, if so - what would be the correct path to the document root? Or do I need to set it via

config setprop moodle host www.my-domain.tld

DNS is a book with seven seals, too :-). I try to desribe in other words:
I have a DNS Provider with some registered domain names. All have two A-Records, one for mydomain.tld and one for *.mydomain.tld. Both point to the static IP x.y.z.81 of my Router. Additionally, I made up a CNAME record for www.mydomain.tld to “mystandarddomain.tld”.
The router forewards any traffic on 80 and 443 to my nethserver. Nethserver itself does not have a red interace (even though IP x.y.z.82 would be available).

If I enter www.mydomain.tld on an external browser, I land where I should be (e.g. on the Moodle page). I I do the same internally (blue), I get a 404. I am not shure what the reason is. Corrently my domains are in transfer from on provider to another - IMO I have the same configuration on for A-Records an CNAMES for both prividers - some domain work as expacted other do not.

@Andy_Wismer - maybe you as a professional, can help me on setting up DNS records correctly?

TIA
Thorsten

That would be perfect :+1:

I am sorry, I guess you confuse me with someone having knowledge on Apache / httpd / Webserver …

No, you don’t need to uninstall moodle, It’s ok to delete the old vhost.
You can setup a vhost in Cockpit.
A secure path is created and shown in the server manager.

The virtual hosts you can create in Cockpit are intended for having custom virtual hosts to host a website or application.
The Nethserver web apps use it’s own virtual hosts. They’re not visible in Cockpit.
It seems in your case you are using the virtualhosts module to redirect to the moodle site.

I think you router does not support hairpin NAT or NAT reflection.
You may add mystandarddomain.tld as alias to the Nethserver. (can be done in the cockpit dashboard)

:smiley: It will be included in the next update.

1 Like

OK, “did” / tried that:

  • deleted the old vhost
  • created a new vhost (including 10-15 host-names dedicated that moodle site)
  • the secure vhost path is created as you wrote

Now, I can access the site only from one hostname - just the first one. Others give a timeout. And it is redirected to “my_standar_internal_name.my_starndard_domain.tld”, which looks really strange.

Seems not to have been the best idea …

Best regards
Thorsten

Which hostname? The same you used in the moodle config?

How do you redirect to the moodle sites from your virtualhosts?

EDIT:

If you want multiple moodle virtualhosts without path I think you need a custom template but I’ll see what I can do.
With the update using more domain names (including path) for a moodle instance should be possible.

Please test the new moodle version:

yum install https://mrmarkuz.dynu.net/mirror/devtest/nethserver-moodle-0.1.4-2.2.g9d7e3de.ns7.noarch.rpm

You can set the virtual host:

config setprop moodle VirtualHost moodle.domain.tld

You can set more virtualhost domains as server alias:

config setprop moodle ServerAlias 'moodle2.domain.tld moodle3.domain.tld'

Apply the settings:

signal-event nethserver-moodle-update

Now Moodle should be reachable via all vhost domain names you configured.

This way no virtualhosts are needed in the UI to redirect to your moodle site.

3 Likes

Oh wow …This looks pretty cool. I will try as fast as possible…

First question: Do you ever sleep? :slight_smile:

Second question: Do I need to upgrade moodle and / or mariadb? I think I have still Moodle 3.5 runing.

TIA
Thorsten

1 Like

It’s moodle 3.9 now but it’s an LTS version. It should be enough to just install the new package to upgrade.

1 Like

Hi Markus,

this weekend is “the weekend” - i dare it. However - My version is 3.5, definitely. You are shure I can do that?

I recommend a backup or snapshot before updating.

The database changed to mariadb 10 so the db needs to be migrated. Moodle should recognize the migrated db and update it.

1 Like

Update performed without errors. Maria DB10 seems to be installed as expected. Maybe you remember my last time problems? This time PhpMyAdmin separates clearly between both instances as expected.

However, there is an error on the old site on the client browser (did not change the vhost so far):

Error: Database connection failed
It is possible that the database is overloaded or otherwise not running properly.
The site administrator should also check that the database details have been correctly specified in config.php

Where is the config.php for moddle located? Is the database transferred automatically? Do you by change chance know what I am supposed to change on the config.php, e.g. the correct port 3306 ->3313?

Oh, and what is / where can I finde the password fĂĽr the MariaDB 10 installation on port 3313. Is it the same is it is for the installation on port 3306?

TIA
Thorsten

2 Likes

Yes - with respect to the db error, it works.

I end up with the correct vhost / alias on the respective error page (see above). “/moodle” is not needed any more and the alias setup works - at least from internal network.

/usr/share/moodle/config.php is templated so you need to use a custom template to make changes permanent.

No, you may migrate it with phpmyadmin.

Yes, it’s the same db root password as for mariadb 5.

Do I need to do any changes?

I guess I will need to do an export of the moodle DB as well as an export of the moodle user.

No, I am sorry, it is not. Where may I find the corresponding information - otherwise I will not be able to do the restore of the exported moodle DB.

Maybe we are not talking about the same user name. In phpmyadmin I use the user “root” with some password I found within nethserver file (I remember to get that pwd 2-3 years ago and never changed it).

Did a counter-check (as I am using a KeePassXC as a Password safe): The password in safe is (still) the same as in /root/.my.cnf = /var/lib/nethserver/secrets/mysql … However, using this pwd, I can not log in onto 3313

TIA

You may login to phpmyadmin with either root or admin with the password in /root/my.cnf, see phpmyadmin wiki entry.

Please check if you can enter mariadb 10 with following command without entering a password:

mysql103

Maybe the mariadb 10 password needs to be set to the one in /root/my.cnf.

Definatly not. the password in /root/.my.cnf does only work for the older mariaDB at 3306. There is no entry to 3313.

does not work either - results in an error message:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/rh-mariadb103/mariadb.sock' (2)