{"id":23763941,"url":"https://github.com/tomashubelbauer/bun-reverse-proxy","last_synced_at":"2026-03-11T10:32:44.521Z","repository":{"id":232253005,"uuid":"757169231","full_name":"TomasHubelbauer/bun-reverse-proxy","owner":"TomasHubelbauer","description":"Bun reverse proxy","archived":false,"fork":false,"pushed_at":"2024-04-08T17:56:42.000Z","size":4,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T02:07:46.271Z","etag":null,"topics":["bun","javascript","proxy-server","reverse-proxy","reverse-proxy-server","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TomasHubelbauer.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-13T23:46:01.000Z","updated_at":"2025-03-06T18:36:25.000Z","dependencies_parsed_at":"2024-04-08T21:50:33.310Z","dependency_job_id":null,"html_url":"https://github.com/TomasHubelbauer/bun-reverse-proxy","commit_stats":null,"previous_names":["tomashubelbauer/bun-reverse-proxy"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TomasHubelbauer/bun-reverse-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomasHubelbauer%2Fbun-reverse-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomasHubelbauer%2Fbun-reverse-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomasHubelbauer%2Fbun-reverse-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomasHubelbauer%2Fbun-reverse-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TomasHubelbauer","download_url":"https://codeload.github.com/TomasHubelbauer/bun-reverse-proxy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TomasHubelbauer%2Fbun-reverse-proxy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30378091,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-11T06:09:32.197Z","status":"ssl_error","status_checked_at":"2026-03-11T06:09:17.086Z","response_time":84,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","javascript","proxy-server","reverse-proxy","reverse-proxy-server","typescript"],"created_at":"2024-12-31T22:13:55.502Z","updated_at":"2026-03-11T10:32:44.474Z","avatar_url":"https://github.com/TomasHubelbauer.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bun Reverse Proxy\n\nThis repository intends to demonstrate using Bun as a reverse proxy and binding\nit to port 80 so that multiple other services running at their own ports can be\naccessed via a plain host name.\n\nThe idea is that the Bun reverse proxy binds to port 80 and it keeps a list of\nservices and their corresponding ports that are running on the same macOS system\nand those services also have their own corresponding `/etc/hosts` entries all\nbeing mapped to the loopback address.\n\n`/etc/hosts`:\n```\n127.0.0.1 service1.localhost # 7001\n127.0.0.1 service2.localhost # 7002\n```\n\nThe `/etc/hosts` file can be edited by running `sudo code /etc/hosts`.\nThe file requires `sudo` for writing (it can be read without it), but VS Code\nrecognizes this and will offer to retry with `sudo` when saving.\n\nI am opting to use the end of line comments in the hosts file as the \"database\"\nof services for the Bun reverse proxy to discover so there is a single source of\ntruth and not two places that can go out of sync (the hosts file for the mapping\nto loopback and whatever other mechanism would there be for the reverse proxy to\nmap the host names to port names on `localhost`).\n\nWhen the user accesses `service1.localhost` or `service2.localhost` in their\nbrowser, the reverse proxy will intercept the request (being bound to port 80,\nthe default for HTTP) and will inspect the host name to see what address to\nforward the request to and proxy the response for.\n\nThey all use the `*.localhost` TLD so they are treated as a secure context by\nthe browser and do not need an HTTPS certificate to use modern web features.\nhttps://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts\n\nI have added sample `service1` and `service2` directories for quick testing.\nThose services can be started by `cd service#` followed by `bun .`.\n\nVS Code Integrated Terminal allows doing multiple ones to run these in parallel.\n\nBun is used because it has a nice built-in HTTP API unlike Node.\n\nIn development, run the reverse proxy using `bun --hot run .`.\nIn \"production\" (running it in the background on the computer), build it and run\nthe executable and detach: `bun build . --compile --outfile reverse-proxy` and\nthen `./reverse-proxy \u0026`.\n\nIf the \"production\" instance is already running, `bun run` will fail to start\nbecause the server will fail to bind to the already taken port 80.\nKill the \"production\" instance first using `pkill reverse-proxy`.\n\nI have extracted this command to the `start` package script so it can be run\nusing `bun start`.\n\nThere is also `bun run build` for making and starting the \"production\" instance.\n\nThe same way, the \"production\" instance won't run if the development one is\nbound to the port 80, so treat running the development instance and building and\nrunning the \"production\" instance as mutually exclusive.\n\nWith this setup, it is possible to run several custom local applications each on\nits own port but access them via user-friendly names and do it using super small\ntooling (just Bun and the compiled reverse proxy binary) and standard approaches\n(the hosts file).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomashubelbauer%2Fbun-reverse-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomashubelbauer%2Fbun-reverse-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomashubelbauer%2Fbun-reverse-proxy/lists"}