{"id":17793963,"url":"https://github.com/nora-soderlund/nodejs-http-proxy","last_synced_at":"2025-04-02T02:20:07.062Z","repository":{"id":98846284,"uuid":"563331296","full_name":"nora-soderlund/NodeJS-HTTP-Proxy","owner":"nora-soderlund","description":"Sets up a HTTP listener on one single public port that you can then route to another internal port.","archived":false,"fork":false,"pushed_at":"2023-01-08T13:03:18.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-07T17:18:45.818Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/nora-soderlund.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,"publiccode":null,"codemeta":null}},"created_at":"2022-11-08T11:51:30.000Z","updated_at":"2022-12-28T15:54:44.000Z","dependencies_parsed_at":"2023-05-07T02:05:48.195Z","dependency_job_id":null,"html_url":"https://github.com/nora-soderlund/NodeJS-HTTP-Proxy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nora-soderlund%2FNodeJS-HTTP-Proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nora-soderlund%2FNodeJS-HTTP-Proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nora-soderlund%2FNodeJS-HTTP-Proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nora-soderlund%2FNodeJS-HTTP-Proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nora-soderlund","download_url":"https://codeload.github.com/nora-soderlund/NodeJS-HTTP-Proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246741197,"owners_count":20826078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-27T11:14:42.036Z","updated_at":"2025-04-02T02:20:07.017Z","avatar_url":"https://github.com/nora-soderlund.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NodeJS-HTTP-Proxy\nSets up a HTTP listener on one single public port that you can then route to another internal port, which can allow you to route different subdomains to different internal servers.\n\n## Get started\n1. Clone the repository\n```git\ngit clone https://github.com/nora-soderlund/NodeJS-HTTP-Proxy\n```\n2. Set up config.json in the root directory as seen in the [examples](#examples) below.\n3. Install the packages and run the start script:\n```npm\nnpm install\nnpm run start\n```\n\n## Examples\nFor http://localhost and http://api.localhost to 2 different web servers:\n```json\n{\n    \"port\": 80,\n\n    \"routes\": [\n        {\n            \"origin\": \"localhost\",\n            \"target\": \"http://localhost:81\"\n        },\n        \n        {\n            \"origin\": \"api.localhost\",\n            \"target\": \"http://localhost:82\"\n        }\n    ],\n    \n    \"processes\": null\n}\n\n```\n\nFor two domains on a single machine, e.g. https://nora-soderlund.se and https://ridetracker.app:\n```json\n{\n    \"port\": 80,\n\n    \"routes\": [\n        {\n            \"origin\": [ \"nora-soderlund.se\", \"www.nora-soderlund.se\" ],\n            \"target\": \"http://localhost:81\"\n        },\n\n        {\n            \"origin\": \"api.nora-soderlund.se\",\n            \"target\": \"http://localhost:82\"\n        },\n        \n        {\n            \"origin\": [ \"ridetracker.app\", \"www.ridetracker.app\" ],\n            \"target\": \"http://localhost:83\"\n        },\n        \n        {\n            \"origin\": \"api.ridetracker.app\",\n            \"target\": \"http://localhost:84\"\n        }\n    ],\n    \n    \"processes\": null\n}\n\n```\n### Processes\nTo automatically run processes (such as the web servers) on the start of the proxy server:\n```json\n{   \n    \"processes\": [\n        {\n            \"command\": \"cmd.exe\",\n            \"options\": [ \"/K\", \"cd ../DeveloperBlog-Server \u0026\u0026 npm start\" ]\n        },\n        \n        {\n            \"command\": \"cmd.exe\",\n            \"options\": [ \"/K\", \"cd ../RideTracker-Server \u0026\u0026 npm start\" ]\n        }\n    ]\n}\n```\n\nTo keep the processes alive if they exit on success (exit code 0) or on failure (negative exit code).\n\nBeware if you enable keep-alive-on-success, that you won't be able to close the process for good without closing the proxy. This can be good if you simply want to restart the server but ensure it's kept alive.\n```json\n{   \n    \"processes\": [\n        {\n            \"command\": \"cmd.exe\",\n            \"options\": [ \"/K\", \"cd ../DeveloperBlog-Server \u0026\u0026 npm start\" ],\n\n            \"rules\": {\n                \"keep-alive-on-success\": false,\n                \"keep-alive-on-error\": true\n            }\n        },\n        \n        {\n            \"command\": \"cmd.exe\",\n            \"options\": [ \"/K\", \"cd ../RideTracker-Server \u0026\u0026 npm start\" ],\n\n            \"rules\": {\n                \"keep-alive-on-success\": false,\n                \"keep-alive-on-error\": true\n            }\n        }\n    ]\n}\n```\n\nTo put a maximum of restart attempts (to avoid a callstack overflow if errors keep appearing on start):\n```json\n{   \n    \"processes\": [\n        {\n            \"command\": \"cmd.exe\",\n            \"options\": [ \"/K\", \"cd ../DeveloperBlog-Server \u0026\u0026 npm start\" ],\n\n            \"rules\": {\n                \"keep-alive-on-success\": false,\n                \"keep-alive-on-error\": true,\n\n                \"keep-alive-error-attempts\": 2\n            }\n        },\n        \n        {\n            \"command\": \"cmd.exe\",\n            \"options\": [ \"/K\", \"cd ../RideTracker-Server \u0026\u0026 npm start\" ],\n\n            \"rules\": {\n                \"keep-alive-on-success\": false,\n                \"keep-alive-on-error\": true,\n\n                \"keep-alive-error-attempts\": 2\n            }\n        }\n    ]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnora-soderlund%2Fnodejs-http-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnora-soderlund%2Fnodejs-http-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnora-soderlund%2Fnodejs-http-proxy/lists"}