Moodle URL change plus mod_proxy

Moodle URL change plus mod_proxy

by Michael Goncharenko -
Number of replies: 5

I am using apache2 with mod_proxy on our gateway. Moodle is installed on the server, which has local IP, behind this gateway.
It's accessible via http://moodle.acts.kiev.ua/ and https://moodle.acts.kiev.ua:8443/, but mod_proxy always uses HTTP for these both addresses.

config.php file contains the last URL (but before the url was http://192.168.34.2/moodle, I changed it).

Now I am having some problems, e.g. when I create a topic on the forum, it redirects me to:
http://moodle.acts.kiev.ua:8443/moodle/mod/forum/view.php?f=3

Please note that 8443 is used for HTTPS, not HTTP.

Also, when Moodle tells me that my message was added to the forum, the page contains the following:
......
<body  class="http:--moodle.acts.kiev.ua:8443-moodle-mod-forum course-1" id="http:--moodle.acts.kiev.ua:8443-moodle-mod-forum-post">
......

Also, when I tried to edit a test inside my course, I received a blank page from server. The following message appeared in httpd-error.log:
[Fri Mar 03 00:35:46 2006] [error] [client 192.168.34.1] PHP Fatal error:  Cannot instantiate non-existent class:   in /usr/local/www/data-dist/moodle/lib/pagelib.php on line 67, referer: https://moodle.acts.kiev.ua:8443/course/view.php?id=2&edit=on

I went to pagelib.php and saw that the function page_map_class was called with $type="http:--moodle.acts.kiev.ua:8443-moodle-mod-quiz-display" or something like that.
Then I inserted a following line there (stop laughing)
 $type = ereg_replace("http:--moodle.acts.kiev.ua:8443-moodle-", "", $type);
the problem has gone awayОдобрить... But some problems seem to stay (as far as i feel, they are because of mod_proxy).

So my questions are:
1. How do I gracefully change the URL moodle installed at?
2. Is it neccessary to reinstall moodle after all I've done to it? Зло

Average of ratings: -
In reply to Michael Goncharenko

Re: Moodle URL change plus mod_proxy

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
I am using apache2 with mod_proxy on our gateway. Moodle is installed on the server, which has local IP, behind this gateway. It's accessible via http://moodle.acts.kiev.ua/ and https://moodle.acts.kiev.ua:8443/, but mod_proxy always uses HTTP for these both addresses.

Could you paste your apache config for this? (just the excerpt with the proxy directives).

Saludos. Iñaki.
In reply to Iñaki Arenaza

Re: Moodle URL change plus mod_proxy

by Michael Goncharenko -

I have deleted itsmile It was something like:

<VirtualHost 195.245.81.42:80>
        ServerName      moodle.acts.kiev.ua
        ServerAdmin    
root@localhost

        AddType         text/html .shtml
        AddHandler      server-parsed .shtml

        ProxyPass / http://192.168.34.2/moodle/
        ProxyPassReverse / http://192.168.34.2/moodle/
</VirtualHost>

And the same VirtualHost (plus SSL directives) for HTTPS.

SSL directives were:

SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /usr/local/etc/apache2/ssl.crt/server.crt
SSLCertificateKeyFile /usr/local/etc/apache2/ssl.key/server.key
SetEnvIf User-Agent ".*MSIE.*" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0

Client used https and mod_proxy used http, I think, the problem was because of this difference.

In reply to Michael Goncharenko

Re: Moodle URL change plus mod_proxy

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
In your first post, you say:

    config.php file contains the last URL

Which one of the two? The http://... one or the http://....:8443/ one? In other words, what is your $CFG->wwwroot ?

Saludos. Iñaki.
In reply to Iñaki Arenaza

Re: Moodle URL change plus mod_proxy

by Michael Goncharenko -

The last from these two is the second:
https://moodle.acts.kiev.ua:8443/

So $CFG->wwwroot = 'https://moodle.acts.kiev.ua:8443';

without trailing slash smile

In reply to Michael Goncharenko

Re: Moodle URL change plus mod_proxy

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers
So $CFG->wwwroot = 'https://moodle.acts.kiev.ua:8443';

Ok, so you are telling Moodle to always build HTTPS urls for all the content it generates.

Then, all the client browsers will try to connect via HTTPS for anything but the initial connections (as all the URLs in the page will be https://...)

Then, to make it work, map your internal IP (192.168.34.2) to name 'moodle.acts.kiev.ua', using your hosts file. This will asure consistency in HTTP headers, both in queries and in responses, and will make the whole thing a lot easier.

Then put this in your virtual hosts

a) For the non-HTTPS one:

<VirtualHost 195.245.81.42:80>
ServerName moodle.acts.kiev.ua
ServerAdmin
root@localhost

ProxyPass / http://moodle.acts.kiev.ua/moodle/
ProxyPassReverse / https://moodle.acts.kiev.ua:8443/
</VirtualHost>

b) For the HTTPS on (plus all of the SSL directives):

<VirtualHost 195.245.81.42:8443>
ServerName moodle.acts.kiev.ua
ServerAdmin
root@localhost

ProxyPass / http://moodle.acts.kiev.ua/moodle/
</VirtualHost>

If I'm not mistaken, this should do it.

Saludos. Iñaki.