The context is that I want to serve a static website inside a docker container so I can have some dedicated metrics, and I want the logs to use stdout/stderr.
To do that I thought of using Lighttpd with an Alpine image.
I found a tip here where we create a link to stdout, but after creating the link the permissions change and lighttpd stops writing to access.log.
I've tried changing server.username
on lighttpd.conf to "root" but it refuses to do so saying '
(server.c.1330) I will not set uid to 0.
I've tried changing the access.log permissions after the link creation with no success.
Is there a way to configure lighttpd to use stdout/stderr?
My currently config:
var.basedir = "/var/www/localhost"
var.logdir = "/var/log/lighttpd"
var.statedir = "/var/lib/lighttpd"
server.modules = ( "mod_access",
"mod_setenv",
"mod_rewrite",
"mod_redirect",
"mod_status",
"mod_simple_vhost",
"mod_evhost",
"mod_alias",
"mod_userdir",
"mod_secdownload",
"mod_fastcgi",
"mod_proxy",
"mod_cgi",
"mod_ssi",
"mod_compress",
"mod_usertrack",
"mod_expire",
"mod_rrdtool",
"mod_accesslog" )
include "mime-types.conf"
server.errorlog = "/var/log/lighttpd/error.log"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "lighttpd"
server.groupname = "wheel"
server.document-root = var.basedir + "/htdocs"
static-file.exclude-extensions = (".php", ".pl", ".cgi", ".fcgi")
url.access-deny = ("~", ".inc")
accesslog.filename = "/var/log/lighttpd/access.log"
index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
My currently Dockerfile:
FROM alpine:3.12
RUN adduser -S lighttpd -G wheel
RUN apk update --no-cache
RUN apk add --update --no-cache \
lighttpd=1.4.55-r1
COPY ./static /var/www/localhost/htdocs/
COPY lighttpd/* /etc/lighttpd/
RUN ln -sf /dev/stdout /var/log/lighttpd/access.log \
&& ln -sf /dev/stderr /var/log/lighttpd/error.log
EXPOSE 80 443
ENTRYPOINT ["/usr/sbin/lighttpd", "-D", "-f", "/etc/lighttpd/lighttpd.conf"]