Who is reading my blog

Having recently created this page, I decided to try analyse my logs to see who is accessing (or trying to hack) my server. In particular, I am interesting if any humans are reading my posts.

I created logsqlifier as a tool that takes logs from multiple sources (eg. nginx and sshd) and ingests them into an sqlite database.

Some general log analysis

One thing that struck me immediately, is how many bots are querying non existing pages

Count of page hits per status code
status_codecount
2002392
40413551

This lead me the look up what these bots are actually trying to access

Top 15 non existing pages bots try to query on my server
request_pathcount
/wp-admin/install.php?step=1266
/robots.txt186
/.git/config96
/.env93
/app/.env58
/api/.env57
/.env.production57
/wp-login.php56
/.env.local56
/.env.bak56
/backend/.env55
/.env.save55
/.env.prod54
/.env.backup54
/.env.dev53

Looking at the valid requests, there are are also some shenanigans there like /?static=1&order=asc

Top 20 page requests with status code 200
request_pathcount
/1414
/favicon.ico199
/static/style.css105
/about_me.html88
/posts/remote_journald_logs.html62
/posts/notes_on_journalctl.html60
/posts/starting_a_blog.html56
/posts/why_do_my_videos_play_so_slow.html48
/posts/kitty_overlays.html44
/posts/monitoring_internet_connection_state/monitoring_my_internet_connection_state.html42
/atom.xml41
/posts/editing_videos_with_ffmpeg.html38
/index.html25
/robots.txt15
/?p=115
/?rest_route=/14
/posts.html10
/posts/monitoring_internet_connection_state/internet-state-grafana-example.webp7
/?static=1&order=asc7
/?rest_route=/wpadverts/v1/classifieds-types7

One assumption I had was that malicious bots would not query the css files (what possible information could they get from there?). It seems that search engine crawlers like googlebot fetch your css pages, but these can easily be identified via the User Agent.

Let's have a look at the User Agents of the requests that are fetch my css sheet.

Top 10 Count per User Agent of query to css file
User AgentRequest Count
Mozilla/5.0 (X11; Linux x86_64; rv:157.0) Gecko/20100101 Firefox/157.038
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/125.0.6422.60 Safari/537.36 Edge/12.24611
Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 Chrome/153.0.8010.52 Mobile Safari/537.36 (compatible; Googlebot/2.1)6
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/117.0.5938.132 Safari/537.365
Mozilla/5.0 (iPhone; CPU iPhone OS 18_7_8 like Mac OS X) AppleWebKit/605.1.15 Version/26.0 Mobile/15E148 Safari/604.13
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/124.0 Safari/537.363
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:156.0) Gecko/20100101 Firefox/156.03
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/102.0.0.0 Safari/537.363
Mozilla/5.0 (Android 15; Mobile; rv:158.0) Gecko/158.0 Firefox/158.03
RootEvidence/1.02

Googlebot does show on there, but a quick search with AI tells me this is a spoofed version and probably a malicious actor, which invalidated my previous assumption.

Are any humans reading my blog?

Filtering the bots out of my traffic logs is challenging because

I tried (with the help of AI) to come up with an SQL query to identify human readers

WITH marked AS (
    SELECT client_ip, timestamp / 86400 AS session, request_path, status_code, user_agent,
           request_path LIKE '%.css' OR request_path LIKE '%.ico'
        OR request_path LIKE '%.webp' AS asset
    FROM nginx_logs
),
human_sessions AS (
    SELECT client_ip, session
    FROM marked
    GROUP BY client_ip, session
    HAVING MAX(user_agent LIKE 'Mozilla/5.0%'
               AND (user_agent LIKE '%Chrome/%' OR user_agent LIKE '%Firefox/%'
                 OR user_agent LIKE '%Safari/%' OR user_agent LIKE '%Edg/%')) = 1
       AND SUM(status_code >= 400) = 0
       AND SUM(asset) > 0
       AND COUNT(DISTINCT CASE WHEN NOT asset THEN request_path END) >= 2
)
SELECT request_path, COUNT(*) AS views
FROM marked JOIN human_sessions USING (client_ip, session)
WHERE NOT asset
GROUP BY request_path
ORDER BY views DESC;
Query to try and identify human traffic on my site

A few things:

And behold the result

Table of all the pages queried by humans
request_pathviews
/65
/about_me.html36
/posts/notes_on_journalctl.html27
/posts/starting_a_blog.html20
/atom.xml14
/posts/remote_journald_logs.html11
/posts/why_do_my_videos_play_so_slow.html10
/posts/monitoring_internet_connection_state/monitoring_my_internet_connection_state.html7
/posts/kitty_overlays.html6
/posts/editing_videos_with_ffmpeg.html6
/index.html1

Notes

Sources