Webbol: A minimal static web server written in COBOL

https://news.ycombinator.com/rss Hits: 17
Summary

Webbol A minimal static web server written in COBOL using GnuCOBOL. Features Serves static files from the current directory Automatic MIME type detection for common file types HTTP status codes: 200 (OK), 403 (Forbidden), 404 (Not Found) Path traversal attack prevention Clean request logging with full HTTP headers Defaults to index.html for root path requests Requirements GnuCOBOL (cobc) compiler POSIX-compatible operating system (Linux, macOS, BSD) make Installing GnuCOBOL macOS: brew install gnucobol Ubuntu/Debian: sudo apt-get install gnucobol Fedora/RHEL: sudo dnf install gnucobol Building Clone or download the repository, then compile: make This will compile all modules and create the webserver executable. To clean build artifacts: make clean Usage Start the server from the directory you want to serve: ./webserver The server will start on port 8080 and serve files from the current directory. Example # Create a test HTML file echo " <html><body><h1>Hello from COBOL!</h1></body></html> " > index.html # Start the server ./webserver # In another terminal, test it curl http://localhost:8080/ Accessing the Server Once running, you can access files via: http://localhost:8080/ - serves index.html from the current directory - serves from the current directory http://localhost:8080/filename.html - serves the specified file - serves the specified file http://localhost:8080/path/to/file.txt - serves files from subdirectories Press Ctrl+C to stop the server. Configuration To change the server port, edit config.cpy and modify the SERVER-PORT value: 01 SERVER-PORT PIC 9 ( 5 ) VALUE 8080 . Then recompile with make . Project Structure webbol/ ├── Makefile # Build configuration ├── README.md # This file ├── config.cpy # Server configuration ├── socket-defs.cpy # Socket structure definitions ├── http-structs.cpy # HTTP data structures ├── file-structs.cpy # File handling structures ├── path-utils.cbl # Path validation and sanitization ├── mime-types.cbl # MIME type detection ├── ...

First seen: 2025-10-03 14:53

Last seen: 2025-10-04 10:57