HTTP to HTTPS redirection not working

I have several Wordpress sites running on a Ubuntu 18.04 server with Cyberpanel, and suddenly the HTTP to HTTPS rewrite rules have stoped working. This is the content of the rewrite rules of all the sites:

Rewrite Rules Added by CyberPanel Rewrite Rule Generator

RewriteEngine On
rewriteCond %{HTTPS} !on
rewriteCond %{HTTP:X-Forwarded-Proto} !https
rewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

End CyberPanel Generated Rules.

BEGIN iThemes Security - No modifiques ni borres esta línea

iThemes Security Config Details: 2

# Pasar a través de la cabecera de autorización.
<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteCond %{HTTP:Authorization} ^(.*)
	RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
</IfModule>

# Desactivar XML-RPC - Seguridad > Ajustes > Ajustes WordPress > XML-RPC
<files xmlrpc.php>
	<IfModule mod_litespeed.c>
		Order allow,deny
		Deny from all
	</IfModule>
</files>

END iThemes Security - No modifiques ni borres esta línea

BEGIN LSCACHE

LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block!

RewriteEngine on CacheLookup on RewriteRule .* - [E=Cache-Control:no-autoflush] RewriteRule \\.object-cache\\.ini - [F,L]

marker CACHE RESOURCE start

RewriteRule wp-content/./[^/](responsive|css|js|dynamic|loader|fonts)\.php - [E=cache-control:max-age=3600]

marker CACHE RESOURCE end

marker LOGIN COOKIE start

RewriteRule .? - [E=“Cache-Vary:wp-postpass_79d407573650a7956aff495926a2288b”]

marker LOGIN COOKIE end

marker FAVICON start

RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]

marker FAVICON end

marker WEBP start

RewriteCond %{HTTP_ACCEPT} “image/webp” [or]
RewriteCond %{HTTP_USER_AGENT} “Page Speed”
RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]
RewriteCond %{HTTP_USER_AGENT} iPhone.*Version/(\d{2}).Safari
RewriteCond %1 >13
RewriteRule .
- [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]

marker WEBP end

marker DROPQS start

CacheKeyModify -qs:fbclid
CacheKeyModify -qs:gclid
CacheKeyModify -qs:utm*
CacheKeyModify -qs:_ga

marker DROPQS end

## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ## # END LSCACHE # BEGIN NON_LSCACHE ## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ## ## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ## # END NON_LSCACHE

BEGIN WordPress

Las directivas (líneas) entre «BEGIN WordPress» y «END WordPress son

generadas dinámicamente y solo deberían ser modificadas mediante filtros de WordPress.

Cualquier cambio en las directivas que hay entre esos marcadores serán sobrescritas.

AddHandler application/x-httpd-php70 .php

ExpiresActive On
ExpiresByType image/jpg “access plus 24 hours”
ExpiresByType image/jpeg “access plus 24 hours”
ExpiresByType image/gif “access plus 24 hours”
ExpiresByType image/png “access plus 24 hours”
ExpiresByType text/css “access plus 24 hours”
ExpiresByType application/pdf “access plus 1 week”
ExpiresByType text/javascript “access plus 24 hours”
ExpiresByType text/html “access plus 5 minutes”
ExpiresByType image/x-icon “access plus 1 year”
ExpiresDefault “access plus 24 hours”


Header set X-Endurance-Cache-Level “2”


RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

END WordPress