https://github.com/dzove855/Bash-web-server Skip to content Toggle navigation Sign in * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} dzove855 / Bash-web-server Public * Notifications * Fork 40 * Star 753 * A purely bash web server, no socat, netcat, etc... License MIT license 753 stars 40 forks Branches Tags Activity Star Notifications * Code * Issues 0 * Pull requests 0 * Discussions * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Discussions * Actions * Projects * Security * Insights dzove855/Bash-web-server This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main BranchesTags Go to file Code Folders and files Name Name Last commit Last commit message date Latest commit History 48 Commits example example LICENSE LICENSE README.md README.md accept.c accept.c accept.patch accept.patch bash-server.busion bash-server.busion bash-server.sh bash-server.sh mime.types mime.types users.csv users.csv View all files Repository files navigation * README * MIT license Bash-web-server A purely bash web server, no socat, netcat, etc... Requirement * bash 5.2 (The patch will be included in bash5.2 - Alpha release already contains the patch) * if bash version is under 5.2, patched loadable accept builtin ( http://git.savannah.gnu.org/cgit/bash.git/tree/examples/loadables /accept.c) is needed, you have to apply accept.patch to your loadable accept.c file which is existed in bash source code, and than build and install the loadable accept builtin into BASH_LOADABLE_PATH specified in bash-server.sh How to The port can be set by the env var: HTTP_PORT The path to accept (Directory) can be set by using: BASH_LOADABLE_PATH Server Methods: * serveHtml (needs DOCUMENT_ROOT envvars) - This will serve the static files * script file - The script need a file as first argument which will be source. The file will need a function named runner, which will be run on each request Basic authentication can be enabled by env var: NEED_AUTH, accounts and passwords are stored in users.csv Problems... Well there's a little problem... since accept doesn't close the connection (Or i'm doing something wrong), the connection will go into TIME_WAIT. This means that we need to wait the time the connection will be closed, after that we can reopen a connection. I will have a look at the source code and probably provide some options, like a bind-address and a close when the FD is closed. UPDATE: Accept has been patched by me. Now we can handle multiple request at the same time, without waiting the TIME_WAIT. To use the new accept, you will need to compile the accept from this repo, a pull request will be send to bash, but it will take some time. Now we can run multiple connection on the same time, since the connection is running in a subshell. Busion Busion is used to source some functions from other repositorys instead of copy/paste (https://github.com/dzove855/busion) TODO * [*] Implement logging and provide a logging format like httpd * [*] Implement multi processing (this will be a huge step, but we need to patch accept) * [*] Implement urlencode/decode to provide readable get data * [*] Implement content-type detection - Use mime type like nginx * [*] Add basic auth * [*] Add cookie handler * [ ] Add session handler About A purely bash web server, no socat, netcat, etc... Resources Readme License MIT license Activity Stars 753 stars Watchers 10 watching Forks 40 forks Report repository Releases No releases published Packages 0 No packages published Contributors 6 * @dzove855 * @cheese1 * @iaGuoZhi * @andersjanmyr * @gothicx * @SaaShup Languages * Shell 73.7% * C 25.6% * Other 0.7% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.