HTTPd is a lightweight HTTP/1.1 server daemon implemented in C. It strictly follows RFC 9110 and RFC 9112 standards to handle HTTP requests, manage connections, and serve static files efficiently .
- HTTP/1.1 Compliance: Implements GET and HEAD methods .
- Daemon Mode: Runs as a background service with PID management.
- Configuration: Parses a custom INI-style configuration file for global settings and VHosts.
- Virtual Hosting: Supports IP-based and Name-based virtual hosts.
- Logging: Access logs for requests and responses.
- Architecture: Modular design separating Server, HTTP parsing, Daemon logic, and Configuration.
- Network: Uses TCP/IPv4 sockets.
- Graceful Shutdown: Handles
SIGINTfor clean termination of sockets and memory.
The project follows strict C99 standards (-std=c99 -pedantic -Werror -Wall -Wextra -Wvla).
To build the httpd executable:
make./httpd [--daemon (start|stop|restart)] [--option value]Common Options:
--pid_file <path>: Path to the PID file (Mandatory).--port <number>: Server port.--ip <address>: Server IP address.--root_dir <path>: Root directory for serving files.
The server can be launched using a configuration file and the helper script:
./config_reader.sh --path-bin ./httpd --path-config config.txt --daemon start
Example Config (config.txt):
[global]
log_file = server.log
log = true
pid_file = /tmp/httpd.pid
[[vhosts]]
server_name = myserver
port = 8080
ip = 127.0.0.1
root_dir = ./www
default_file = index.html
- Memory Management: Zero leaks allowed.
- Error Handling: Returns correct HTTP status codes (200, 400, 403, 404, 405, 505) .
- Security: Handles null bytes and malformed requests safely.