Skip to content

Lighttpd configuration

Jan Tojnar edited this page Mar 2, 2020 · 14 revisions

Table of Contents

lighttpd configuration

 url.rewrite-once += (
 "^/selfoss/favicon.ico$" => "/selfoss/public/favicon.ico",
 "^/selfoss/favicons/(.*)$" => "/selfoss/data/favicons/$1",
 "^/selfoss/thumbnails/(.*)$" => "/selfoss/data/thumbnails/$1",
 "^/selfoss/([^\?]*\.(js|ico|gif|jpg|png|css|asc|txt|eot|woff|woff2|ttf|svg|map))(\?.*)?$" => "/selfoss/public/$1",
 "^/selfoss/(user\.(js|css))(\?.*)?$" => "/selfoss/$1",
 "^/selfoss/index.php(.*)$" => "$0",
 "^/selfoss/([^\?]*)(\?(.*))?" => "/selfoss/index.php?$3",
 "^/selfoss/public/" => "$0",
 "^/selfoss/(.*)" => "/selfoss/index.php$1"
 )

This is in the case that you have selfoss installed in a subdirectory named selfoss, like http://yourdomain/selfoss/

If you have installed selfoss at the root folder of your web server, then you just need to remove selfoss references from the rules above.

Note (alternative setup): probably a more terse and a bit more secure (restrictive) setup is

  url.rewrite-once = (
    "^/selfoss/favicon.ico$" => "/selfoss/public/favicon.ico",
    "^/selfoss/favicons/(.*)$" => "/selfoss/data/favicons/$1",
    "^/selfoss/thumbnails/(.*)$" => "/selfoss/data/thumbnails/$1",
    "^/selfoss/(user\.(js|css))(\?.*)?$" => "/selfoss/$1",
    "^/selfoss/([^\?]*\.(js|ico|gif|jpg|png|css|asc|txt|eot|woff|woff2|ttf|svg|map))(\?.*)?$" => "/selfoss/public/$1",
    #"^/selfoss/(.*?)(\?.+)?" => "/selfoss/index.php/$1$2",
    "^/selfoss/(.*)" => "/selfoss/index.php$1"
  )

Optional: Compression settings

It is possible to set up automatic compression for the javascript as

  server.modules += ( "mod_compress" )
  compress.cache-dir         = "/var/www/cache/compress/"
  compress.filetype          = ("text/plain", "text/html", "text/javascript")

The compression of the feed pages themselves can be arranged by php by adding

  zlib.output_compression = On

to php.ini (check, where is it on your system), or by

  php_flag zlib.output_compression On

in .htaccess file, which is still consulted by php even though it is running under lighttpd

Upgrading from selfoss 2.17 or lower

Since version 2.18, selfoss uses query strings to bust cache. If you used the directives similar to the ones above, you will need to add support for query strings – replace

 "^/selfoss/(.*.(js|ico|gif|jpg|png|css|asc|txt|eot|woff|ttf|svg))$" => "/selfoss/public/$1",

with

 "^/selfoss/([^\?]*.(js|ico|gif|jpg|png|css|asc|txt|eot|woff|ttf|svg))(\?.*)?$" => "/selfoss/public/$1",

Upgrading from selfoss 2.18 or lower

Since version 2.19, selfoss builds map files for easier debugging of client code. If you used the directives similar to the ones above, you might want to modify the configuration to mention the `map` extension:

    "^/selfoss/([^\?]*\.(js|ico|gif|jpg|png|css|asc|txt|eot|woff|woff2|ttf|svg|map))(\?.*)?$" => "/selfoss/public/$1",

If you use customization, you might also want to add

    "^/selfoss/(user\.(js|css))(\?.*)?$" => "/selfoss/$1",

These files were previously included in the main CSS/JS bundle built at run-time but since we now delegate the asset bundling to Parcel, they need to be loaded separately.