OpenLiteSpeed 1.6.11 breaks rewrite rules

elos4

New Member
#1
Hi, this is my vhost configuration that has been working for several months.
However, an update to 1.6.11 results in the rewrite rules not being applied and all requests -- except for files in document root and sub directories -- throwing a 404 error. Had to downgrade to 1.6.10 to fix it.

Strace on openlitespeed reveals that the rewriterules are not being applied and that the server is not looking for relevant cache files or redirecting the request to the upstream proxy. No other change has been made on the server.

In other words, I can have a perfectly working 1.6.10 server, do an apt upgrade now, and get 404 errors on my website after a restart of OLS.

I get it back in working condition if I overwrite the /usr/local/lsws directory with the backup (1.6.10)


Code:
docRoot                   /var/www/wordpress/

errorlog $VH_ROOT/logs/error.log {
useServer 1
logLevel DEBUG
rollingSize 10M
}

accesslog $VH_ROOT/logs/access.log {
logFormat               %t %l%u  %>s  _%b_      -%{Content-Encoding}o-  %D      \"%r\" %h
useServer 0
rollingSize 10M
keepDays 10
compressArchive 1
}

index  {
  useServer               0
  indexFiles              index.php index.html
}

context /phpmyadmin/ {
  location                /var/www/phpmyadmin
  allowBrowse             1
  indexFiles              index.php

  accessControl  {
    allow                 *
  }

  addDefaultCharset       off

  phpIniOverride  {









  }
}

rewrite  {
  enable                  1
  autoLoadHtaccess        0
  rules                   <<<END_rules
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/domainname/%{REQUEST_URI}/index-https.html -s
RewriteRule . /wp-content/cache/supercache/domainname/%{REQUEST_URI}/index-https.html  [L]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} -s
RewriteRule . %{REQUEST_URI} [L]
RewriteRule ^/(.*)$ http://upstream-proxy/$1 [P,E=proxy-host:domainname]
  END_rules

}

module cache {
#          1
checkPrivateCache   0
checkPublicCache    1
maxCacheObjSize     200000
maxStaleAge         300
qsCache             0
reqCookieCache      0
respCookieCache     0
ignoreReqCacheCtrl  1
ignoreRespCacheCtrl 0

enableCache         1
expireInSeconds     86000
enablePrivateCache  0
privateExpireInSeconds 3600
  ls_enabled              1
}
 
Last edited:

tiyl

New Member
#2
I'm running into the same problems: WordPress Multisite installation, worked perfectly until 1.6.10.
After the 1.6.11 update, all URLs except the home pages throw 404 ols error pages, clearly the rewrite rules aren't working.
Went back to 1.6.10, which resolves the problem for the moment.

Any tips how to get the rewrite engine to work as expected?

(Using Ubuntu 18.04.4 LTS)
 
Last edited:

tiyl

New Member
#4
I'm sorry I can't give many details, because I restored to 1.6.10, so I have no debug or error log available.

What happened was that the backend of my WordPress Multisite as well as the home pages worked, while all permalinks for articles on all sites of the multisite installation showed the openlitespeed 404 page. Neither updating the permalink settings nor disabling caching altogether helped.

These are the rewrite rules for the domains in the openlitespeed virtual hosts settings (basic multisite rewrite rules):
Code:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^/ - [L]
RewriteRule ^/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^/([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
In addition, the .htaccess in the web root contains (note: only the first 7 lines are "custom code", everything else is automatically configured/added by the WordPress LiteSpeed Cache Plugin):
Code:
### Workaround certbot rewrite
RewriteCond %{REQUEST_URI} ^.well-known/.*
### Workaround certbot end
### Forcing HTTPS rule start
RewriteCond %{SERVER_PORT} 80
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
### Forcing HTTPS rule end

# BEGIN LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
<IfModule LiteSpeed>
RewriteEngine on
CacheLookup on
RewriteRule .* - [E=Cache-Control:no-autoflush]
RewriteRule ^min/\w+\.(css|js) - [E=cache-control:no-vary]

### 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_b6e92292681670bf96f65e6f29683834"]
### marker LOGIN COOKIE end ###

### marker FAVICON start ###
RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]
### marker FAVICON end ###

</IfModule>
## 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! ##
### marker MINIFY start ###
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} ^(.*)/min/(\w+)\.(css|js)$
RewriteCond %1/wp-content/cache/$2/$1.$2 -f
RewriteRule min/(\w+)\.(css|js) wp-content/cache/$2/$1.$2 [L]
</IfModule>
### marker MINIFY end ###

## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END NON_LSCACHE
One additional detail that caught my eye: I'm using Ubuntu 18.04.4 LTS and I really only need to exchange the openlitespeed binary in /usr/local/lsws/bin with the 1.6.10 version to get the sites running again. But somehow it seems strange that both binaries have the exact same size.
Code:
/usr/local/lsws/bin# ll openlitespeed*
-rwxr-xr-x  1 root root 7292824 Apr  8 19:49 openlitespeed*
-rwxr-xr-x  1 root root 7292824 Apr  8 19:54 openlitespeed.1-6-11*

/usr/local/lsws/bin# ./openlitespeed -v
LiteSpeed/1.6.10 Open
    module versions:
    modgzip 1.1
    cache 1.62
    modinspector 1.1
    uploadprogress LSIAPI_VERSION_STRING
    mod_security 1.2
(built: Mon Mar 16 20:16:39 UTC 2020)
    module versions:
    modgzip 1.1
    cache 1.62
    modinspector 1.1
    uploadprogress LSIAPI_VERSION_STRING
    mod_security 1.2
  
/usr/local/lsws/bin# ./openlitespeed.1-6-11 -v
LiteSpeed/1.6.11 Open
    module versions:
    modgzip 1.1
    cache 1.62
    modinspector 1.1
    uploadprogress 1.1
    mod_security 1.3
(built: Thu Apr  2 14:45:36 UTC 2020)
    module versions:
    modgzip 1.1
    cache 1.62
    modinspector 1.1
    uploadprogress 1.1
    mod_security 1.3
Hope that helps.
 
Top