0

After Moodle elearning system update, the redirection from http to https is not working anymore.

Environment: Debian 9, Bitnami Moodle appliance, Apache web server

Port 80 and 443 are opened in firewall. You can access the web site via https and it's working.

I tried this https://docs.bitnami.com/installer/apps/moodle/#how-to-force-https-redirection-with-apache with no effect.

Everytime I enter URL without https, I get

Bad Request Your browser sent a request that this server could not understand. Reason: You're speaking plain HTTP to an SSL-enabled server port. Instead use the HTTPS scheme to access this URL, please.

This is from apache log:

[Wed Aug 08 16:16:45.827527 2018] [mpm_event:notice] [pid 3827:tid 140588913918464] AH00491: caught SIGTERM, shutting down
[Wed Aug 08 16:16:49.917673 2018] [ssl:warn] [pid 4503:tid 140413525754368] AH01909: localhost:443:0 server certificate does NOT include an ID which matches$
[Wed Aug 08 16:16:49.954349 2018] [ssl:warn] [pid 4504:tid 140413525754368] AH01909: localhost:443:0 server certificate does NOT include an ID which matches$

[Wed Aug 08 16:16:49.966243 2018] [mpm_event:notice] [pid 4504:tid 140413525754368] AH00489:Apache/2.4.29 (Unix) OpenSSL/1.0.2n configured -- resuming norm$
[Wed Aug 08 16:16:49.966287 2018] [core:notice] [pid 4504:tid 140413525754368] AH00094: Command line: '/opt/bitnami/apache2/bin/httpd.bin -f /opt/bitnami/ap$

I also tried to modify /opt/bitnami/apps/moodle/conf/httpd-prefix.conf with this lines:

DocumentRoot "/opt/bitnami/apps/moodle/htdocs" RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/(.*) http://www.moodle.mysite.com/$1 [R,L] Include "/opt/bitnami/apps/moodle/conf/httpd-app.conf" 

Didn't help. After every change I restarted Apache, deleted browser cache and tried to load the web page.

Thank you.

2
  • Are you running this behind a load balancer or something? Commented Aug 8, 2018 at 16:44
  • Hi Michael, no, there is no load balancer. It worked before the update. The only change was the update of Moodle. Commented Aug 8, 2018 at 20:05

1 Answer 1

0

According to https://docs.bitnami.com/installer/apps/moodle/#how-to-force-https-redirection-with-apache the RewriteRule should be https instead of http as appear in the above message, also the DocumentRoot directive should reference the Apache directory, not the moodle one:

<VirtualHost _default_:80> DocumentRoot "/opt/bitnami/apache2/htdocs" RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L] ... </VirtualHost> 
1
  • Thank you, Carlos, you are right, I changed it to https, but when I change the DocumentRoot to apache, I get Moodle inicialization screen when I enter moodle.mysite.com and when I enter http://... I still get Bad request. :( Commented Aug 14, 2018 at 9:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.