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.

culter
  • 507
  • 2
  • 9
  • 16

1 Answers1

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>
  • 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 https://moodle.mysite.com and when I enter http://... I still get Bad request. :( – culter Aug 14 '18 at 09:16