A small HTTP server for learning how NGINX-style server architecture works.
MIT License · C · POSIX sockets · poll(2)
fzgnix is a from-scratch learning project that explores the core ideas behind NGINX, inspired by Inside NGINX: High Performance Web Server Through Source Code. It currently runs as one process with a non-blocking TCP listener and a poll(2) event loop. Startup initializes configuration, logging, and modules; each client connection moves through request parsing, module dispatch, response writing, and cleanup.
This is a teaching implementation. It is not a production web server, a drop-in NGINX replacement, or a compatible NGINX configuration parser.
Read Inside NGINX: High Performance Web Server Through Source Code on Amazon. To request the free version, fill out this form.
The server starts its core cycle, opens a listener, then moves each ready connection through a compact HTTP request pipeline.
The event loop is a connection state machine: it waits for socket readiness, accepts or reads available data, and switches a completed response to writable events.
The HTTP exchange diagram shows the request and response lifecycle handled by the current implementation.
fzgnix demonstrates a few architectural ideas in a compact codebase. Production NGINX has a much broader configuration model, process architecture, event backends, protocol support, and module ecosystem.
| Area | fzgnix | Production NGINX |
|---|---|---|
| Configuration | Small subset of one-token directives | Nested contexts with context-dependent directives and routing |
| Processes | One process handles accepted clients | Master and worker process model |
| I/O events | poll() scans configured client slots |
Platform event backends such as epoll or kqueue |
| HTTP handling | Parses request line and headers; serves / and /health |
HTTP phases and modules for static files, proxying, TLS, and more |
| Connection life | One request, then close and release the connection pool | Persistent connections and richer lifecycle handling |
- Configurable TCP listen port and client connection limit
- Non-blocking IPv4 sockets and a single-process
poll(2)event loop - Incremental HTTP/1.x header parsing with an 8 KiB request buffer
GETandHEADsupport for/and/health400,404, and405responses- Per-connection memory pools, partial response writes, and timestamped logging
- Module registry and a small NGINX-inspired configuration subset
The root setting is parsed but static-file serving is not implemented yet. Each connection handles one request and then closes.
Requirements: a C11 compiler, make, and a POSIX-compatible environment.
make
./ngnix -c ngnix.confThe server listens on 0.0.0.0:8080 by default. In another terminal, try:
curl -i http://127.0.0.1:8080/
curl -i http://127.0.0.1:8080/healthPress Ctrl-C to stop the server. The configuration file accepts a small subset of NGINX-style directives; see ngnix.conf.
| Path | Purpose |
|---|---|
src/core |
Startup cycle, config subset, memory pool, logger, and module registry |
src/event |
poll(2) backend and connection state machine |
src/http |
HTTP request parsing and built-in response module |
src/os/unix |
Unix socket setup and non-blocking descriptor helpers |
See ARCHITECTURE.md for a component walkthrough and ROADMAP.md for planned milestones.
fzgnix is released under the MIT License.



