{"id":19722139,"url":"https://github.com/eshengsky/node-proxy","last_synced_at":"2025-07-19T04:35:52.506Z","repository":{"id":30833588,"uuid":"123697629","full_name":"eshengsky/node-proxy","owner":"eshengsky","description":"High performance HTTP and reverse proxy server based on Node.js. 基于 Node.js 的高性能 HTTP 及反向代理服务器，类似nginx。","archived":false,"fork":false,"pushed_at":"2022-12-14T02:05:02.000Z","size":1572,"stargazers_count":75,"open_issues_count":9,"forks_count":25,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-29T22:36:24.725Z","etag":null,"topics":["http-proxy","nginx","node-http-proxy","node-proxy","node-proxy-server","nodejs-server","proxy","proxy-server","reverse-proxy"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eshengsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-03T14:09:19.000Z","updated_at":"2025-02-20T03:27:32.000Z","dependencies_parsed_at":"2023-01-14T18:00:27.203Z","dependency_job_id":null,"html_url":"https://github.com/eshengsky/node-proxy","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/eshengsky/node-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshengsky%2Fnode-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshengsky%2Fnode-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshengsky%2Fnode-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshengsky%2Fnode-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eshengsky","download_url":"https://codeload.github.com/eshengsky/node-proxy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eshengsky%2Fnode-proxy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265889138,"owners_count":23844539,"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":["http-proxy","nginx","node-http-proxy","node-proxy","node-proxy-server","nodejs-server","proxy","proxy-server","reverse-proxy"],"created_at":"2024-11-11T23:16:32.483Z","updated_at":"2025-07-19T04:35:52.437Z","avatar_url":"https://github.com/eshengsky.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://github.com/eshengsky/node-proxy\"\u003e\u003cimg src=\"https://github.com/eshengsky/node-proxy/blob/master/web/static/img/node-proxy.png\" height=\"120\" align=\"right\"\u003e\u003c/a\u003e\n\n# Node Proxy\n\n基于 Node.js 的高性能 HTTP 及反向代理服务器，类似于 [Nginx](http://nginx.org/)。\n\n[![Build Status](https://travis-ci.org/eshengsky/node-proxy.svg?branch=master)](https://travis-ci.org/eshengsky/node-proxy)\n\n### 为什么使用Node Proxy\n\n如果你的项目符合以下任一点，你就可以尝试使用 Node Proxy：\n* 你的项目本身就是基于 Node.js，你希望代理服务器也使用相同的技术；\n* 你的团队更熟悉 JavaScript，而不是 C/C++/Lua；\n* 你希望有一个 WebUI 配置界面，而不是过时的纯文本配置方式；\n* 你想要能随时配置路由规则，但又不想重启代理服务器；\n* Nginx 已经满足不了你了 —— 例如：你想在代理端发请求验证用户的登录状态，而不是在浏览器端才去验证；\n* ...\n\n### 界面预览\n\n![image](./preview.png)\n\n### 功能与特色\n\n* 静态文件处理\n    * 支持目录或指定单独文件\n    * 方便的文件选择器\n    * 支持服务端文件预览\n* URL 重写\n* 反向代理\n    * 基于 [node-http-proxy](https://github.com/nodejitsu/node-http-proxy)\n    * 支持负载均衡\n    * 支持按服务器性能自定义分配权重\n* 自定义响应\n    * 可以无需发布直接配置页面\n    * 网页版 [VSCode](https://code.visualstudio.com/) 体验\n* 服务端缓存\n    * 立即从缓存中返回响应内容，极速用户体验\n    * 支持自定义缓存 key\n* 身份验证控制\n    * 无需开发人员自己判断登录、跳转登录\n* WebUI 配置界面\n    * 美观、优雅、现代的 UI 设计\n    * 支持内置账号、Gitlab两种登录方式\n    * 支持权限管理 (只读、可写)\n* 修改规则配置后无需重启服务器\n* 集成日志查看神器 [chrome-extension-server-log](https://github.com/eshengsky/ServerLog/tree/master/chrome-extension-server-log)\n* Node Proxy 处理的网页都支持 [调试模式](#调试模式)\n\n### 与 Nginx 的比较\n\n|   服务器   | 并发能力 | 静态资源处理能力 | 配置方式 | 配置备份 | 是否需重启 | 扩展能力 |\n|:----------:|----------|---------------|--------------|------------|------------|------------|\n| Nginx      | 很强 | 很快 | 纯文本配置方式，易拼写错误或重复，配置存储在本地文件中。 | 通常需手动备份，也没有配置修改记录。 | 通常需重启服务。 | 强，但需要掌握 C、Lua 等语言，且要运维去担任开发角色。 |\n| Node Proxy | 很强 | 一般（但通常有CDN） | WebUI 配置界面，支持下拉选择、格式检查等，配置存储在数据库中。 | 任何配置操作（包括删除）都会在数据库中存档以供追溯和恢复。| 支持运行时修改并生效，无需重启。 | 强，全端技术统一（JavaScript），可方便地添加任何想要的逻辑。 |\n\n### 流程图\n\nNode Proxy 处理请求从接收到响应的基本流程示意：  \n[Node Proxy Workflow](https://www.processon.com/view/link/5b46c90be4b00c2f18c9b5f7)\n\n### 快速开始\n\n#### 下载源码\n\n点击 `Clone or download` 下载源码，或在 [Release](https://github.com/eshengsky/node-proxy/releases) 页面下载指定版本代码。\n\n#### 安装依赖\n\n```bash\n$ yarn\n```\n\n#### 启动 Node Proxy\n\n```bash\n$ yarn start\n```\n\n访问 [http://localhost:9000/node-proxy/](http://localhost:9000/node-proxy/)，默认账号：admin/123456.\n\n如果你使用了 [chrome-extension-server-log](https://github.com/eshengsky/ServerLog/tree/master/chrome-extension-server-log)，默认 secret key 请填写：`node-proxy_secret_key`.\n\n### 配置说明\n\nNode Proxy 中的配置可分为 2 类：系统配置和规则配置。\n\n* 系统配置\n\n一般是服务器启动时就需要获取并生效的配置参数，如数据库连接等，需要手动修改配置文件，修改后必须重启 Node-Proxy。\n\n配置文件必须放置于 `/config/` 目录下，你可以通过启动服务器时传入变量 `config` 来指定当前环境使用哪个配置文件。如：\n\n```bash\n$ config=test node server.js\n```\n\n会自动读取 `/config/test.js` 配置文件。  \n如果没有显式传入 `config`， 则会取 `NODE_ENV` 环境变量作为配置文件名，如：\n\n```bash\n$ NODE_ENV=production node server.js\n```\n这会自动读取 `/config/production.js` 配置文件。  \n\n#### 配置项说明\n\n##### ssl\nObject 类型，SSL 相关设置\n\n##### ssl.enable\nBoolean 类型，是否创建 HTTPS 服务器\n\n##### ssl.key\nString 类型，私钥文件路径，必须是绝对路径\n\n##### ssl.cert\nString 类型，证书文件路径，必须是绝对路径\n\n##### proxyTimeout\nNumber 类型，反向代理的超时时长，单位毫秒\n\n##### keepAlive\nNumber 类型，反向代理keep-alive时长，单位毫秒\n\n##### job\nString 类型，自动更新的调度规则，配置格式可参照 https://github.com/node-schedule/node-schedule#cron-style-scheduling\n\n##### staticDirPath\nString 类型，文件选择器中的静态文件根目录\n\n##### debugParam\nString 类型，调试模式的参数名\n\n##### methods\nArray 类型，请求方式配置\n\n##### permissions\nArray 类型，页面的身份验证\n\n##### auth\nObject 类型，Node-Proxy系统的访问权限配置\n\n##### auth.local\nArray 类型，用户名密码方式的用户列表，数组元素是用户对象，属性username是登录名，属性password是密码，密码必须经过md5加密\n\n##### auth.gitlab\nObject 类型，Gitlab - OAuth2方式登录的相关配置\n\n##### auth.gitlab.enable\nBooleana 类型，是否开启Gitlab登录方式\n\n##### auth.gitlab.baseURL\nString 类型，Gitlab的地址，可以配置成内网部署的Gitlab站点URL\n\n##### auth.gitlab.clientID\nString 类型，Gitlab应用的ID\n\n##### auth.gitlab.clientSecret\nString 类型，Gitlab应用的Secret\n\n##### auth.gitlab.callbackURL\nString 类型，Gitlab应用的回调地址\n\n##### auth.editableUsers\nArray 类型，允许编辑的用户，如：['user1', 'user2']，配置为 ['*'] 则所有用户都有编辑权限\n\n##### serverFileCache\nObject 类型，静态资源服务端缓存设置\n\n##### serverFileCache.enable\nBoolean 类型，是否开启服务端缓存\n\n##### serverFileCache.max\nNumber 类型，所有缓存值的总大小限制\n\n##### serverFileCache.maxAge\nNumber 类型，缓存过期时间，单位毫秒\n\n##### db\nObject 类型，数据库配置\n\n##### db.mongodb\nString 类型，MongoDB 连接字符串，支持集群\n\n##### db.redisKeyPrefix\nString 类型，Redis 键前缀\n\n##### db.redisConnect\nString 或 Array 类型，Redis 连接信息，如果配置为一个数组则视为集群\n\n##### serverlog\nObject 类型，[ServerLog](https://github.com/eshengsky/ServerLog/blob/master/README_zh.md#configoptions) 模块配置参数\n\n* 规则配置\n\n规则配置是指与请求相关联的路由、服务器、缓存等配置信息，通过访问 [http://localhost:9000/node-proxy/](http://localhost:9000/node-proxy/) 进行修改，系统会定时自动更新配置，故修改后无需重启服务器。\n\n### 环境部署\n\n推荐使用 [pm2](https://pm2.io/runtime/) 进行 Node.js 的进程管理和持久运行。  \n注：你可以指定当前环境要使用的配置文件，详见 [配置说明](#配置说明)。\n\n#### 安装pm2\n\n```bash\n$ yarn global add pm2\n```\n\n#### 启动服务\n\n```bash\n$ config=production NODE_ENV=production pm2 start server.js -i 0\n```\n\n### 日志查看\n\n* 本地开发环境，直接在终端中查看日志\n* 部署到环境上后，使用 `pm2 logs` 查看日志\n* 使用 Chrome 扩展程序 [chrome-extension-server-log](https://github.com/eshengsky/ServerLog/tree/master/chrome-extension-server-log) 在开发者工具 (F12) 中查看日志\n\n### 调试模式\n\n可以方便地查看前后端日志、前端错误信息、存储信息等，尤其是在移动设备上。  \n启动方式：在当前页面 URL 中加入参数 `h5debug=true`。  \n基于 [eruda](https://github.com/liriliri/eruda) 打造。\n\n### 使用帮助\n\n登录后访问 http://localhost:9000/node-proxy/help/ 查看帮助。\n\n### 测试\n\n#### 功能测试\n```bash\n$ yarn test\n```\n\n#### 性能测试\n见 [benchmark](https://github.com/eshengsky/node-proxy/tree/master/benchmark) 目录。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feshengsky%2Fnode-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feshengsky%2Fnode-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feshengsky%2Fnode-proxy/lists"}