Reverse Proxy + Moodle, easy or right way?

Reverse Proxy + Moodle, easy or right way?

by Jose Perez Paris -
Number of replies: 2

Hi everyone,

This is my first contribution to the community.

So, I have a Dell server with Proxmox 7 that is connected to the internet through a Mikrotik router. In the Mikrotik I have the needed NAT port redirections (80 and 443) to the server's fixed IP.

In Proxmox I have two LXC containers, first one with NPM (Nginx proxy manager) and second one with Debian 10 + Apache + Moodle

I also have a Synology NAS that makes Backups, but that is not part of the question.

The Moodle install is a migration from another server and, after several attempts, it's working right with standard http:// requests.

Then I knew about NPM and made another Debian container and install NPM on it without issues. I setup the Debian host in NPM, with the IP address of the container and the URL and redirected 80 and 443 ports in the router to the fixed IP of the NPM and everything works as expected, you can access the moodle instance through the reverse proxy and without changing a word in the config.php of the moodle.

So far so good; but now I woud like to go with https, but would like it to work only in the proxy and go native (http) to the moodle (no certs or so in the moodle server, only in the proxy) but all the tries went bad and I only got two kind of responses:

1.- Moodle not working and I got a screen with something saying that Moodle detects the proxy and blah blah

2.- Moodle seems to work but is like text only

So, I wonder if a veteran user could be so kind to explain how to make it work the right way.

At the moment I don't need the reverse proxy (intalled it because I have plans to install OwnCloud in another container and will need it) so I'm safe, but I have been request to go with https:// so I also would like to know if my idea of going with certificates in the proxy and not in the server is OK or would be better to install certbot in the Moodle server and have certificates in the moodle server right now and use the "convert to https" function in Moodle?

Large one to be the first one smile

Average of ratings: -
In reply to Jose Perez Paris

Re: Reverse Proxy + Moodle, easy or right way?

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

If you have a reverse proxy such that the back-end web server(s) isn't (aren't) bound to the Moodle web site domain name then you need $CFG->reverseproxy = true; in config.php.

If the TLS/SSL connection terminates at the reverse proxy such that the back-end web server is serving unencrypted HTTP then you also need $CFG->sslproxy = true;.

Average of ratings: Useful (3)
In reply to Leon Stringer

Re: Reverse Proxy + Moodle, easy or right way?

by Jose Perez Paris -
Hi Leon,

Very short answer compared to the question!!! smile smile smile

Now seriously, great simple and concise answer, thank you very much. I'll try in the next days.

Again, thank you so much for your sharing your knowledge and being clear enought.