0

I am a beginner with traefik, lighttpd, docker compose, and I am trying to get logging working for lighttpd under docker compose.

My lighttpd.conf file contains:

server.modules = (
        "mod_debug",
        "mod_accesslog",
        "mod_dirlisting",
        "mod_indexfile",
)

server.document-root = "/var/www/lighttpd8081/html"
server.errorlog = "/var/log/lighttpd/error.log"
server.port = 80

mimetype.assign = (
  ".html" => "text/html",
  ".txt" => "text/plain",
  ".jpg" => "image/jpeg",
  ".png" => "image/png"
)

accesslog.filename = "/var/log/lighttpd/access.log"

debug.log-request-header-on-error = "enable"
debug.log-file-not-found = "enable"
dir-listing.activate = "enable"
dir-listing.hide-dotfiles = "disable"

My docker-compose.yml file contains:

  lighttpd:
    image: sebp/lighttpd
    container_name: lighttpd
    restart: unless-stopped
    volumes:
      - /srv/docker/lighttpd/lighttpd/etc/lighttpd.conf:/etc/lighttpd/lightpd.conf
      - /srv/docker/lighttpd/lighttpd/log/error.log:/var/log/lighttpd/error.log
      - /srv/docker/lighttpd/lighttpd/log/access.log:/var/log/lighttpd/access.log
      - /var/www/lighttpd8081/html:/var/www/lighttpd8081/html
    ports:
      - "80"
    tty: true
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.lighttpd.rule=Host(`example.com`) && PathPrefix(`/.well-known/acme-challenge`)"
      - "traefik.http.routers.lighttpd.entrypoints=web"
      - "traefik.http.routers.lighttpd.tls=false"
    networks:
      - proxy

I can get a "404 File Not Found" from lighttpd (via traefik). But I cannot get logging from lighttpd into access.log and/or error.log.

I do not know why the file is not served by lighttpd and I do not know why logging is not written by lighttpd. I can get logging on the tty from lighttpd by running docker compose up without -d

lighttpd          | 172.18.0.4 example.com - [22/Oct/2022:13:08:11 +0000] "GET /.well-known/acme-challenge/indext.txt HTTP/1.1" 404 341 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15"

The source file exists:

root@snape:/srv/docker/traefik# ls -l /var/www/lighttpd8081/html/.well-known/acme-challenge/
total 8
-rw-r--r-- 1 root root 13 Oct 22 09:25 index.html
-rw-r--r-- 1 root root 13 Oct 22 12:50 index.txt

I guessed I might not be getting access.log and error.log from lighttpd because of

tty: true

but if I remove that, lighttpd does not start at all:

lighttpd          | chmod: /dev/pts/0: No such file or directory
lighttpd          | 2022-10-22 13:25:09: (configfile.c.1608) opening errorlog '/dev/pts/0' failed: Permission denied
lighttpd          | 2022-10-22 13:25:09: (server.c.1564) Opening errorlog failed. Going down.
gctwnl
  • 171
  • 11
  • If you remove Traefik from the equation, what behavior do you see? Make sure lighttpd is working correctly before you start introducing complex proxy configurations. – larsks Oct 22 '22 at 16:53
  • Actually, cancel that; you have a typo in the your volume mapping for the `lighttpd.conf` configuration file, in `/srv/docker/lighttpd/lighttpd/etc/lighttpd.conf:/etc/lighttpd/lightpd.conf` you have mis-spelled `lighttpd.conf` as `lightpd.conf`. – larsks Oct 22 '22 at 17:01
  • Thank you. Getting very frustrated I moved to `nginx` and had a setup working in 30 minutes. I'll test if this was my stupid mistake. – gctwnl Oct 29 '22 at 11:43
  • I tested this and indeed this was my stupid mistake. @larsks you could enter the answer and get the credits for spotting my stupid mistake. – gctwnl Oct 29 '22 at 11:57

0 Answers0