sophuwu.site > manhttpd
Golang HTTP service to allow users to search linux manual in their own system, with wildcards or regex (name + page summary), then convert to a dark themed html page with hyperlinks to named pages.
Clone this repository git clone https://sophuwu.site/manhttpd

Go Man Page Web Server

This Go application serves man pages over HTTP. It allows users to view, search, and browse man pages directly from a web browser. The server dynamically integrates the hostname into the pages and provides static file support (CSS and favicon).

Features

Dependencies

Ubuntu/Debian dependency installation: sudo apt-get install mandoc -y

Golang installation instructions at go.dev.

lazy script to install go 1.23.1 updated 7-SEP-2024

#!/bin/bash
# delete incompatible versions
[ -d /usr/local/go ] && sudo rm -rf '/usr/local/go' ;
# downlaod compatible version
which wget || sudo apt-get install wget -y && wget https://go.dev/dl/go1.23.1.linux-amd64.tar.gz ;
# install into system  
[ -f go1.23.1.linux-amd64.tar.gz ] && sudo tar -C /usr/local -xzf go1.23.1.linux-amd64.tar.gz ;
# add to bin 
[ -f /usr/local/go/bin/go ] && sudo ln -s /usr/local/go/bin/go /bin/go ;
# hope it works 
go version ;

Compiling The Binary

# download the source code
git clone "https://sophuwu.site/manhttpd" && cd manhttpd
 
# build the binary with go
go build -ldflags="-s -w" -trimpath -o build/manhttpd

# install the binary into the system
sudo install ./build/manhttpd /usr/local/bin/manhttpd

Using As Systemd Service:

The provided service file should work on most systems, but you may need to edit it to fit your needs.
It will open a http server on port 8082 available through all network interfaces.
You should change the ListenAddr variable to 127.0.0.1 and use a secure reverse proxy if you are on a public network.
TLS and authentication are not implemented in this server.

Variables in the service file:

Environment Variables:
HOSTNAME: Used for http proxying.
ListenPort: If unset, the server will default to 8082.
ListenAddr: This should be changed if you are on a public network.
MANDOCPATH: Path to the mandoc executable. If unset, the server will attempt to find it in the PATH.

System Variables:

User: Reccomended to use your login user so the service can access your ~/.local man pages. But not required.
ExecStart: The path to the manhttpd binary. If you installed it to /usr/local/bin, you can leave it as is.
WorkingDirectory: This should be /tmp since the server doesn’t need to write to disk.

# to edit paths, users, and environment variables if needed
nano manhttpd.service 

# install the service file to systemd and load it
sudo install manhttpd.service /etc/systemd/system/manhttpd.service
sudo systemctl daemon-reload

# start the service and check its status
sudo systemctl start manhttpd.service
sudo systemctl status manhttpd.service

# to keep the service running after a reboot
sudo systemctl enable manhttpd.service

# to stop the service and disable it from restarting
sudo systemctl stop manhttpd.service
sudo systemctl disable manhttpd.service

# to edit the server configuration after installation
sudo systemctl edit manhttpd.service
sudo systemctl daemon-reload 
sudo systemctl reload-or-restart manhttpd.service
sudo systemctl status manhttpd.service

Accessing the Web Interface

Open your web browser and navigate to http://localhost:8082 if you are running the server locally or the remote server’s IP address or hostname.
To search with regex, you can use the search bar at the top of the page with -r at the beginning of the search term.
To look into a specific section, you can add -sN to the search term where N is the section number.
If no section is specified, the server will display with the same priority as the defualt man command.
Glob patterns are also supported in the search bar if regex not enabled.

Example Usage:

Notes and Warnings

Help and Support

I don’t know how this git pull thing works. I will try if I see any issues. I’ve never collaborated on code before. If you have any suggestions, or questions about anything I’ve written, I would be happy to hear your thoughts.
contant info: skisiel.com or sophuwu.site