Migrating from apache2 to OpenLiteSpeed (OLS)

#1
I have been using Apache2 web server behind Nginx reverse proxy for several years.
I recently read that OLS is much faster than Apache2, so I started testing.

The Nginx reverse proxy server manages TLS (LE) certs. It is configured so that when a user enters the URL
Code:
example.com
http://example.com
https://example.com
www.example.com
http://www.example.com
https://www.example.com
it is always redirected to
Code:
https://www.example.com
This is all solved by the Nginx reverse proxy.
The nginx reverse proxy communicates with Apache2 unencrypted on port 80, because encryption is provided by Nginx.
I want to leave everything as is and replace Apache with OLS.
So far I've launched a website without www, but not www.
I would like to put the config file here, but I don't know where it is located.

By the way, my apache config looks like this
Code:
<VirtualHost *:80>
    ServerAdmin admin@example.com
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/www.example.com/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    RemoteIPHeader X-Real-IP
    RemoteIPInternalProxy 192.168.20.10
  <Directory "/var/www/www.example.com">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>
How should I configure OLS to work properly?
 
Last edited:
#2
In the future, maybe you can consider to setup an OpenliteSpeed to handle the https and websites without a proxy.
The force www and SSL can be done by the following rewriterules.
Code:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
To set up a virtual host with OLS, you can use the web admin GUI to configure the necessary settings.
 
#3
Thank you very much for the information. I am just getting to know OLS.
Even before reading your message, my config contained this (I replaced my real domain with example.com)

Code:
docRoot                   $VH_ROOT/html
vhDomain                  example.com
vhAliases                 www.example.com
enableGzip                1

index  {
  useServer               0
  indexFiles              index.html
  autoIndex               0
}

rewrite  {
  enable                  1
  rules                   <<<END_rules
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
  END_rules

}
Of course, I did that before configuring OLS.

Code:
sudo mkdir /usr/local/lsws/www.example.com
sudo mkdir /usr/local/lsws/www.example.com/{conf,html,logs}
sudo chown lsadm:lsadm /usr/local/lsws/www.example.com/conf
sudo nano /usr/local/lsws/www.example.com/html/index.html
HTML:
<html>
    <head>
        <title>Welcome to OLS</title>
    </head>
    <body>
        <h1>Welcome to OLS</h1>
    </body>
</html>
If I use this configuration, the redirection works correctly, but the web page does not display.
If I cancel rewrite in the settings and remove this code

Code:
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
The configuration looks like this:

Code:
docRoot                   $VH_ROOT/html
vhDomain                  example.com
vhAliases                 www.example.com
enableGzip                1

index  {
  useServer               0
  indexFiles              index.html
  autoIndex               0
}
Redirecting to https: // www of course doesn't work, but I can see the content of the website.
 
Top