1

I have Moodle (elearning system) web application installed on Debian 9 with Apache web server. It is a bitnami appliance, but the only difference is the folder structure. I configured redirection from http to https several months ago. Recently I updated Moodle to the latest version and the redirection stopped working. I'm trying to manage it to work for several days, but with no success.

I turned on debug mode in apache logs. When I enter http://elearning.mymoodlesite.com in web browser, I get Bad request error.

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.

In Apache's access_log file is "Get / HTTP/1.0" 400 362 error

This is bitnami.conf, where I modified configuration according to this https://docs.bitnami.com/aws/components/apache/#how-to-force-https-redirection-for-an-application :

# Default Virtual Host configuration.

<IfVersion < 2.3 >
  NameVirtualHost *:80
  NameVirtualHost *:443
</IfVersion>

<VirtualHost _default_:80>
  DocumentRoot "/opt/bitnami/apache2/htdocs"
  **RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteRule / https://elearning.mymoodlesite.com/$1 [R,L]**
  <Directory "/opt/bitnami/apache2/htdocs">
    Options -Indexes
    AllowOverride All
    <IfVersion < 2.3 >
      Order allow,deny
      Allow from all
    </IfVersion>
    <IfVersion >= 2.3 >
      Require all granted
    </IfVersion>
  </Directory>

  # Error Documents
  ErrorDocument 503 /503.html

  # Bitnami applications installed with a prefix URL (default)
  Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>

# Default SSL Virtual Host configuration.

<IfModule !ssl_module>
  LoadModule ssl_module modules/mod_ssl.so
</IfModule>

Listen 443
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH !aNULL !eNULL !LOW !3DE$
SSLPassPhraseDialog  builtin
SSLSessionCache "shmcb:/opt/bitnami/apache2/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300

<VirtualHost _default_:443>
  DocumentRoot "/opt/bitnami/apache2/htdocs"
  SSLEngine on
SSLCertificateFile "/opt/bitnami/apache2/conf/mymoodlesite.pem"
SSLCertificateKeyFile "/opt/bitnami/apache2/conf/mymoodlesite.key"

  <Directory "/opt/bitnami/apache2/htdocs">
    Options -Indexes
    AllowOverride All
<IfVersion < 2.3 >
      Order allow,deny
      Allow from all
    </IfVersion>
    <IfVersion >= 2.3 >
      Require all granted
    </IfVersion>
  </Directory>

  # Error Documents
  ErrorDocument 503 /503.html

  # Bitnami applications installed with a prefix URL (default)
  Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>

# Bitnami applications that uses virtual host configuration
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf"

I experimented with RewriteRule, changed

RewriteRule / https://elearning.mymoodlesite.com/$1 [R,L]

to

RewriteRule ^/(.*) https://elearning.mymoodlesite.com/$1 [R,L]

and some other combinations, but it didn't help.

Complete record from apache error_log, when I enter http://elearning.mymoodlesite.com:

[Mon Aug 13 10:51:30.664911 2018] [ssl:info] [pid 13931:tid 140708832802560] [client 195.168.40.226:44320] AH01964: Connection to child 149 established (server elearning.mymoodlesite.com:443)

[Mon Aug 13 10:51:30.665158 2018] [ssl:info] [pid 13931:tid 140708832802560] [client 195.168.40.226:44320] AH01996: SSL handshake failed: HTTP spoken on HTTPS port; trying to send HTML error page

[Mon Aug 13 10:51:30.665210 2018] [ssl:info] [pid 13931:tid 140708832802560] SSL Library Error: error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request -- speaking HTTP to HTTPS port!?

[Mon Aug 13 10:51:30.665329 2018] [headers:debug] [pid 13931:tid 140708832802560] mod_headers.c(900): AH01503: headers: ap_headers_error_filter()

[Mon Aug 13 10:51:30.852250 2018] [ssl:info] [pid 13931:tid 140708824409856] [client 195.168.40.226:44326] AH01964: Connection to child 150 established (server elearning.mymoodlesite.com:443)

[Mon Aug 13 10:51:30.852356 2018] [ssl:info] [pid 13931:tid 140708824409856] [client 195.168.40.226:44326] AH01996: SSL handshake failed: HTTP spoken on HTTPS port; trying to send HTML error page

[Mon Aug 13 10:51:30.852377 2018] [ssl:info] [pid 13931:tid 140708824409856] SSL Library Error: error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request -- speaking HTTP to HTTPS port!?

[Mon Aug 13 10:51:30.852426 2018] [headers:debug] [pid 13931:tid 140708824409856] mod_headers.c(900): AH01503: headers: ap_headers_error_filter()

culter
  • 507
  • 2
  • 7
  • 16

0 Answers0