The linux framebuffer video is available in ffmpeg via the fbdev device.
> ffprobe -f fbdev -i '/dev/fb0'
[fbdev @ 0x2308100] w:1920 h:1080 bpp:32 pixfmt:bgra fps:25/1 bit_rate:1658880000
[fbdev @ 0x2308100] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, fbdev, from '/dev/fb0':
Duration: N/A, start: 1673953008.518392, bitrate: 1658880 kb/s
Stream #0:0: Video: rawvideo (BGRA / 0x41524742), bgra, 1920x1080, 1658880 kb/s, 25 fps, 1000k tbr, 1000k tbn
That should tell you some metadata about the video source, useful for testing. Replace ffprobe with ffmpeg to do the usual video transcoding:
> ffmpeg -f fbdev -i '/dev/fb0' -f matroska -crf 0 -filter:v 'scale=-1:720' - | mpv
That will send the encoded video stream to stdout, which should be played by mpv after a few seconds of buffering. If your headless server is accessible via SSH, you can reuse this pipe technique and do:
ssh server ffmpeg -f fbdev -i '/dev/fb0' -f matroska -crf 0 -filter:v 'scale=-1:720' - | mpv
This must be run from a machine with a GUI and a video player installed (mpv in the example above) which has SSH access to server. Alternatively, the video stream can be exposed over HTTP. Looking at this answer, for example, you could do this:
ffmpeg -f fbdev -i '/dev/fb0' -f mp4 -movflags frag_keyframe+empty_moov -listen 1 http://localhost:8080/
That makes ffmpeg a one-shot webserver, where you can point your favorite video player to, e.g. vlc http://localhost:8080/. Your browser might insist to downloading that file, which will probably require wrapping the url in some HTML.
Making a proper streaming web-server is a larger topic, and probably difficult to get right if you intend to have many visitors and support various devices. The topic seems to have been answered multiple times, but for other video sources.
I hope this will take you a step in the right direction.
Note: If you want to mess around with your framebuffer content while you're testing this, you can issue cat /dev/urandom >/dev/fb0 and cat /dev/zero >/dev/fb0