doku:αΩ « Wikidd »

des 𝞹-pes, du sudo maso & la main sur l'hacker !

User Tools

Site Tools


prog:server:caddy

Caddy

Start here

First Conf

{
    debug
}

localhost {

    root * /home/duke/www/
    file_server browse
    templates
    try_files index.html index.php


    @php {
        path *.php
    }
    reverse_proxy @php localhost:9000 {
        transport fastcgi {
            split .php
        }
   }
}

Heavy monitoring

Yet simple using zgrep when your log files are compressed in .gz format.

Moving to your log files location :

$ cd /var/log/caddy 

Using zgrep -c to count defined occurrences, here “GET” request on “/anarchism/” uris with “200” code status :

$ zgrep -c -e 'GET /anarchism/.* 200' access*gz
access-2021-01-13T15-59-14.474.log.gz:244
access-2021-01-24T22-17-10.833.log.gz:410
access-2021-02-06T19-31-11.064.log.gz:404 

Quick monitoring

Using jq with bash (or any equivalent) :

Log formatting

$ tail -fn0 /var/log/caddy/access.log \
| jq '[ .request | .headers."User-Agent"[0], .remote_addr, .uri ]'

URI pattern match

$ jq 'if(.request.uri|match(".*rss.*")) \
      then .request.uri else empty end' /var/log/caddy/access.log \
| sort -u

Group by IP,URI

jq '.request | .remote_addr+":"+.uri' /var/log/caddy/access.log | tr -d '"' \
  | sed -E 's/:{1}[0-9]{4,5}:{1}\// \//' \
  | tr -d '[' \
  | tr -d ']' \
  | awk '{ t[$0]++ }END{ for(i in t) { printf "%5d %s\n",t[i],i } }' \
  | sort -g

References

/home/duke/www/dukeart/wiki/data/pages/prog/server/caddy.txt · Last modified: 2022/02/15 00:46 by duke