2

I have a default lighttpd installation with server.document-root = /var/www/html

/etc/lighttpd/lighttpd.conf

server.modules = (
    "mod_indexfile",
    "mod_access",
    "mod_alias",
    "mod_redirect",
)

server.document-root        = "/var/www/html"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80

# strict parsing and normalization of URL for consistency and security
# https://redmine.lighttpd.net/projects/lighttpd/wiki/Server_http-parseoptsDetails
# (might need to explicitly set "url-path-2f-decode" = "disable"
#  if a specific application is encoding URLs inside url-path)
server.http-parseopts = (
  "header-strict"           => "enable",# default
  "host-strict"             => "enable",# default
  "host-normalize"          => "enable",# default
  "url-normalize-unreserved"=> "enable",# recommended highly
  "url-normalize-required"  => "enable",# recommended
  "url-ctrls-reject"        => "enable",# recommended
  "url-path-2f-decode"      => "enable",# recommended highly (unless breaks app)
 #"url-path-2f-reject"      => "enable",
  "url-path-dotseg-remove"  => "enable",# recommended highly (unless breaks app)
 #"url-path-dotseg-reject"  => "enable",
 #"url-query-20-plus"       => "enable",# consistency in query string
)

index-file.names            = ( "index.php", "index.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.conf.pl"
include "/etc/lighttpd/conf-enabled/*.conf"

#server.compat-module-load   = "disable"
server.modules += (
    "mod_compress",
    "mod_dirlisting",
    "mod_staticfile",
)

Then I have some other webpages under /var/www/rss which should be served when I use https://myip/rss or when I use https://rss.mydomain.dev. So I introduced this config

/etc/lighttpd/conf-enabled/20-tt-rss.conf

$HTTP["url"] =~ "^/rss/" {
    server.document-root = "/var/www/rss"
    dir-listing.activate = "disable"
    $HTTP["url"] =~ "^/rss/(locale|classes|schema|lock|utils|cache|templates|\.git)/" {
        url.access-deny = ( "" )
    }
    expire.url = (
        "/rss/css/" => "access plus 1 days",
        "/rss/images/" => "access plus 1 days",
        "/rss/js/" => "access plus 1 days",
        "/rss/feed-icons/" => "access plus 1 hours"
    )
} else $HTTP["host"] == "rss.mydomain.dev" {
    server.document-root = "/var/www/rss"
    dir-listing.activate = "disable"
    $HTTP["url"] =~ "rss.mydomain.com/(locale|classes|schema|lock|utils|cache|templates|\.git)/" {
        url.access-deny = ( "" )
    }
    expire.url = (
        "rss.mydomain.dev/css/" => "access plus 1 days",
        "rss.mydomain.dev/images/" => "access plus 1 days",
        "rss.mydomain.dev/js/" => "access plus 1 days",
        "rss.mydomain.dev/feed-icons/" => "access plus 1 hours"
    )   
}

When using http://myip/rss/ I get a 404

404 error

When using http://rss.mydomain.dev I get the "Placeholder page"

Placeholder page

I am clearly missing something but as new user to lighttpd I don't see what.

4
  • Do the logs say anything useful? Maybe with debug logging enabled?
    – sebix
    Feb 2, 2021 at 8:00
  • nothing in error.log and only this in access.log: [02/Feb/2021:08:34:41 +0100] "GET /rss/ HTTP/1.1" 404 341 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0"
    – papanito
    Feb 2, 2021 at 8:01
  • are files from /etc/lighttpd/conf-enabled/ loaded automatically or does it need to be configured somewhere?
    – papanito
    Feb 2, 2021 at 8:13
  • your config says include "/etc/lighttpd/conf-enabled/*.conf". I would enable debug logging to get more insights
    – sebix
    Feb 3, 2021 at 11:49

1 Answer 1

0

lighttpd debug variables provide noisy details on how lighttpd processes the request, and might be useful to you.

Another option is to strace -s 1024 the lighttpd process, make a request, and review the filesystem accesses.

lighttpd configuration processing occurs procedurally, in the order configured. If you have multiple conditions which set server.document-root, then the last condition that matches the request and sets server.document-root is the one that takes effect for server.document.root. (global settings are treated as if they were set first, no matter where in the config they appear)

While you included your lighttpd.conf in the question, you did not include the complete configuration. Try running lighttpd -f /etc/lighttpd/lighttpd.conf -p to print the complete configuration.

Aside: incorrect use: $HTTP["url"] =~ "rss.mydomain.com/(locale|classes|schema|lock|utils|cache|templates|\.git)/" The $HTTP["url"] is the url-decoded and normalized url-path. The url-path does not include the authority ("rss.mydomain.com") Similarly, your use of expire.url with "rss.mydomain.dev" is incorrect.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .