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 ( The host name is set via

    config setprop moodle host
    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.


    What I observe is when calling e.g. other-domain.other-tld, the browser is redirected to (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:

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


    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

NethServer Version: 7.9.2009
Module: Moodle / Wiki

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?


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

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?


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

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

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


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

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.


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.


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