{"id":13459099,"url":"https://github.com/Tencent/nohost","last_synced_at":"2025-03-24T16:31:21.830Z","repository":{"id":38323293,"uuid":"223688419","full_name":"Tencent/nohost","owner":"Tencent","description":"基于 Whistle 实现的多账号多环境远程配置及抓包调试平台","archived":false,"fork":false,"pushed_at":"2025-01-09T03:12:56.000Z","size":13674,"stargazers_count":1439,"open_issues_count":42,"forks_count":163,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-03-19T03:07:11.182Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://nohost.pro","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tencent.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2019-11-24T03:44:16.000Z","updated_at":"2025-03-15T16:26:09.000Z","dependencies_parsed_at":"2024-01-13T17:58:27.914Z","dependency_job_id":"868131a3-1862-4b10-82af-ffc867531dd1","html_url":"https://github.com/Tencent/nohost","commit_stats":{"total_commits":1054,"total_committers":17,"mean_commits":62.0,"dds":0.09677419354838712,"last_synced_commit":"92cb52070976c3e48f3095df3983b297baeb240e"},"previous_names":[],"tags_count":74,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2Fnohost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2Fnohost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2Fnohost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tencent%2Fnohost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tencent","download_url":"https://codeload.github.com/Tencent/nohost/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245308571,"owners_count":20594272,"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-07-31T09:01:03.938Z","updated_at":"2025-03-24T16:31:21.167Z","avatar_url":"https://github.com/Tencent.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Nohost\n[![NPM version](https://img.shields.io/npm/v/@nohost/server.svg?style=flat-square)](https://npmjs.org/package/@nohost/server)\n[![node version](https://img.shields.io/badge/node.js-%3E=_8.0.0-green.svg?style=flat-square)](http://nodejs.org/download/)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/Tencent/nohost/pulls)\n[![License](https://img.shields.io/npm/l/@nohost/server.svg?style=flat-square)](https://www.npmjs.com/package/@nohost/server)\n\nNohost 是基于 [Whistle](https://github.com/avwo/whistle) 实现的多用户多环境配置及抓包调试系统，不仅具备 Whistle 的所有功能，并在 Whistle 基础上扩展了一些功能，且支持多人多环境同时使用，主要用于部署在公共服务器上供整个部门（公司）的同事共同使用，具有以下功能：\n1. 环境共享：前端无需配后台环境，后台无需配前端环境，其他人无需配任何环境\n2. 抓包调试：远程实时抓包调试，支持各种 Whistle 规则，以及通过链接分享抓包数据\n3. 历史记录：可以把环境配置及抓包数据沉淀下来，供后续随时切换查看\n4. 插件扩展：可以通过插件扩展实现诸如 [inspect](https://github.com/whistle-plugins/whistle.inspect)，[vase](https://github.com/whistle-plugins/whistle.vase)，[autosave](https://github.com/whistle-plugins/whistle.autosave) 等功能\n5. 对外接口：提供对外接口，可供发布系统、CI等工具操作，实现自动化增删查改环境配置\n\n![效果图](https://user-images.githubusercontent.com/11450939/40436253-28a90f28-5ee5-11e8-97a5-fd598e32e0df.gif)\n\n# 目录\n[一. 准备](#prepare)\n\n[二. 安装](#install)\n\n[三. 设置](#settings)\n\n[四. 访问](#access)\n\n[五. 账号](#accounts)\n\n[六. 配置](#config)\n\n[七. 规则](#Whistle)\n\n[八. 开发](#development)\n\n[九. 加群](#add)\n\n\n## \u003ca href=\"#prepare\" id=\"prepare\"\u003e一. 准备\u003c/a\u003e\n安装 Nohost 之前，建议先做好以下工作：\n\n1. 准备一台服务器，假设IP为：10.1.2.3（以你自己的服务器为准，建议4核8G以上的配置）\n2. 准备一个域名（以下假设为：nohost.imweb.io），并把 DNS 指向上述服务器（10.1.2.3）\n3. 收集涉及域名的证书对，只支持 `xxx.key` 和 `xxx.crt`（非必须，但建议用正式的证书，否则要么 Nohost 里面无法查看 HTTPS 的内容，要么每个访问 Nohost 的客户端都要安装一遍根证书）\n\n\u003e 申请域名的好处是可以直接用域名访问管理及账号页面，手机也可以通过域名设置代理访问 Nohost，方便记忆及输入\n\n## \u003ca href=\"#install\" id=\"install\"\u003e二. 安装\u003c/a\u003e\n首先，需要安装Node（建议使用最新的LTS版本）：[Node](https://nodejs.org/en/)\n\nNode安装成功后，通过npm安装 `nohost`：\n``` sh\nnpm i -g @nohost/server --registry=https://r.npm.taobao.org\n```\n安装完成后执行启动命令：\n``` sh\nn2 start\n```\n\u003e 也可以启动时直接设置当前 Nohost 服务到域名 `n2 restart -o nohost.imweb.io`\n\u003e Nohost 的默认端口为 8080，如果需要自定义端口，可以通过 `n2 restart -p 80` 设置。\n\u003e 如果命令行提示没有对应命令，检查下系统环境变量 `PATH` 配置，看看 Nohost 安装后生成的命令所在目录是否已添加到 `PATH`。\n\n重启 `Nohost`：\n``` sh\nn2 restart\n```\n\n停止 `Nohost`：\n``` sh\nn2 stop\n```\n\n重置管理员账号：\n``` sh\nn2 restart --reset\n```\n\n## \u003ca href=\"#settings\" id=\"settings\"\u003e三. 设置\u003c/a\u003e\n安装启动成功后，打开管理员页面 `http://10.1.2.3:8080/admin.html#system/administrator`，输入默认用户名（`admin`）和密码（`123456`），打开系统配置后：\n\u003e 其中 `10.1.2.3` 表示Nohost运行的服务器IP，具体根据实际 ServerIP 替换\n1. 修改管理员的默认账号名和密码（**不建议使用默认账号及密码，如果忘记管理员账号名或密码，可以通过 `n2 restart --reset` 重置**）\n2. 设置Nohost的域名（将申请的域名填上，如果需要设置多个域名，可以通过逗号 `,` 分隔，也可以通过启动参数 `-o www.xxx.com,www.yyy.com` 设置）\n3. 上传涉及的 key 和证书（证书只支持 `.crt` 格式）\n\n![admin](https://user-images.githubusercontent.com/11450939/69247822-0c010b00-0be6-11ea-8b03-5a0ae4b12c6e.gif)\n\n**Note: 设置的域名 DNS 一定要指向该IP，否则可能出现不可用状态，上述配置会自动重启服务，建议避免频繁操作**\n\n## \u003ca href=\"#access\" id=\"access\"\u003e四. 访问\u003c/a\u003e\nNohost 本身就是一个代理，可以直接配置浏览器或系统代理访问，也可以通过 Nginx反向代理访问，为方便大家使用，针对不同的人群可以使用不同的方案（以下用 `nohost.imweb.io` 表示 Nohost 的域名，具体域名需要自己申请及设置）。\n\n#### 前端开发\n前端开发建议使用最新版的 [Whistle](https://github.com/avwo/whistle)，可以通过以下两种方式访问 Nohost：\n\n1. 直接在 Whistle 上配置远程规则\n    ``` txt\n    @http://nohost.imweb.io:8080/whistle.nohost/cgi-bin/plugin-rules\n    ```\n    \u003e 上述配置表示 Whistle 从 `http://nohost.imweb.io:8080/whistle.nohost/cgi-bin/plugin-rules` 获取 Nohost 的生成的入口规则，并且如果 Nohost 规则有变会自动更新规则，这些规则是由 Nohost 上传证书的域名及界面 `配置/入口配置` 配置的规则自动生成（具体参见后面的**配置**），这些规则可以自动过滤掉无关请求，只会把相关的请求转到Nohost。\n\n    当然这种直接手动配置在 Whistle 上还不是最好的方式，更建议的方式是把这些规则集成到插件里面，这样开发者只需安装插件即可。\n2. **【强烈推荐】** 集成 Whistle 插件，具体参考：[https://github.com/nohosts/whistle.nohost-imweb/blob/master/dev.md](https://github.com/nohosts/whistle.nohost-imweb/blob/master/dev.md)\n\n#### 后台开发\n后台开发推荐使用 Chrome 的 [SwitchyOmega](https://chrome.google.com/webstore/detail/proxy-switchyomega/padekgcemlokbadohgkifijomclgjgif) 配置代理规则 （如上述代理配置 `nohost.imweb.io` + `8080`），如果不想所有请求都转到 Nohost，可以配置 SwitchyOmega 的自动切换或者用PAC脚本代替，也可以参考 `nohost-client` 打包一个客户端：[https://github.com/nohosts/client](https://github.com/nohosts/client)。手机端可以直接配代理，或者通过 VPN App 设置代理，如 iPhone 可以用 `detour`。\n\n#### 其他人员\n非开发人员尽量使用客户端、APP、或通过外网转发的方式，减少他们的接入成本，如何打包客户端参考：[https://github.com/nohosts/client](https://github.com/nohosts/client)；手机等同后台开发的配置方式。\n\n#### 外网访问\n一般 Nohost 是部署在公司内网，外网是不可以直接访问，需要通过接入层（如：Nginx）转发。\n\n## \u003ca href=\"#accounts\" id=\"accounts\"\u003e五. 账号\u003c/a\u003e\n安装好插件或配置好代理后，打开相关页面（这些页面的域名必须在上面上传证书里面，如果没有需要额外配置，具体参考下方 **配置** 说明），即可看到页面左下脚出现一个小圆点，点击小圆点可以进行切换环境：\n\n![证书列表](https://user-images.githubusercontent.com/29788452/104725825-9652e980-576d-11eb-980c-69cdade67da4.png)\n\n![Whistle插件列表](https://user-images.githubusercontent.com/11450939/69324924-4ae59e00-0c84-11ea-994c-7c3914257470.png)\n\n![打开页面](https://user-images.githubusercontent.com/11450939/69325133-9b5cfb80-0c84-11ea-8213-8c64d5365538.png)\n\n![点击按钮](https://user-images.githubusercontent.com/11450939/69325935-ecb9ba80-0c85-11ea-8cca-3c73bee69fd6.png)\n\n\u003e 如果页面左下脚没出现小圆点，可以看下面 **配置** 说明\n第一次打开小圆点只有一个 **正式环境**，需要管理员添加账号：\n![添加账号](https://user-images.githubusercontent.com/29788452/104725989-d9ad5800-576d-11eb-9d25-34e06d0bb41e.png)\n\n添加完账号后，打开独立的环境选择页面 `http://nohost.imweb.io:8080`：\n\n![选择环境页面](https://user-images.githubusercontent.com/29788452/104726057-f34e9f80-576d-11eb-9ec2-c429887f354d.png)\n![个人账号页面](https://user-images.githubusercontent.com/11450939/69358193-6fac3680-0cc1-11ea-9406-0f036d888d7c.png)\n![image](https://user-images.githubusercontent.com/11450939/69358459-d92c4500-0cc1-11ea-8263-08bb216fc357.png)\n\n创建完环境后，可以在环境里面配置任何 Whistle 规则，跟普通到本地 Whistle 功能一模一样，甚至更多。每个实例可以建立上百个账号，每个账号可以建立上百个环境，具体取决于你到机器性能。\n\n## \u003ca href=\"#config\" id=\"config\"\u003e六. 配置\u003c/a\u003e\n默认情况下，只有证书里面域名的请求才会被转发到各个账号，且 html 类型的内容会自动注入小圆点，但在实际应用中你可能会遇到以下问题：\n\n#### 域名证书问题\n有些域名只涉及 http 请求，不涉及 https 的请求不需要证书，或者某些敏感及第三方域名无法获得证书，这类域名可以通过在 `配置 -\u003e 入口配置` 里面设置：\n![入口配置](https://user-images.githubusercontent.com/29788452/104726133-0e211400-576e-11eb-9138-0ded4282bce5.png)\n\n入口配置的规则有三种（`#xxx`表示注释）：\n``` txt\npattern #转发到Nohost，如果是html页面则注入小圆点\n-pattern #转发到Nohost，不注入小圆点\n--pattern #不转发到Nohost，且不注入小圆点\nx)-pattern #x为整数（正负数零都可以），表示手动设置优先级，默认为0\n```\npattern 参见：[https://wproxy.org/whistle/pattern.html](https://wproxy.org/whistle/pattern.html)，匹配顺序是从上到下，每个请求只会匹配其中一个，证书里面到域名优先级默认最低，可以通过 `1)` 设置优先级。\n\n如：\n``` txt\nke.qq.com\n-*.url.cn\n--localhost.**\n-1)**.qq.com\n```\n表示：\n1. 所有 `ke.qq.com` 的请求都转发到Nohost，且所有 html 都注入小圆点\n2. 所有 `xxx.url.cn` 的请求都转发到Nohost，但不注入小圆点\n3. 所有 `localhost.xxx.yyy...` 的请求都不转发到Nohost，且不注入小圆点\n4. 所有 `qq.com` 的子代域名请求都转发到Nohost，但不注入小圆点，并优先级设为 `-1` ，确保证书里面的 `qq.com` 子域名可以正常注入小圆点\n\n## \u003ca href=\"#whistle\" id=\"whistle\"\u003e七. 规则\u003c/a\u003e\n这个是 Nohost 主进程 Whistle，所有请求都会通过该 Whistle，并通过该进程的 whistle.nohost 插件进行账号管理及请求转发，主进程 Whistle 在生产环境下无法查看抓包数据，可用于设置规则及全局插件管理，如：屏蔽一些请求等等，更多内容参见后面的文档。\n\n**详细内容参见文档：[https://nohost.pro/](https://nohost.pro/)**\n\n## \u003ca href=\"#development\" id=\"development\"\u003e八. 开发\u003c/a\u003e\n开发环境搭建：\n```bash\ngit clone git@github.com:Tencent/nohost.git\n# 切换到dev开发分支\ngit checkout dev\n# 安装依赖\nnpm install\n# 启动页面构建\nnpm run dev\n# 启动 Nohost\nnpm start\n```\n\u003e 修改页面后需要手动刷新\n\n\n## \u003ca href=\"#add\" id=\"add\"\u003e九. 加群\u003c/a\u003e\n欢迎大家加入Nohost交流群。考虑到群二维码有时效限制，请大家扫码加好友，验证回复 `Nohost` ，会统一将大家拉进群。\n![二维码](https://user-images.githubusercontent.com/29788452/105933529-8bf7f000-6089-11eb-9e0a-6ab40604e355.png)\n\n# 参与贡献\n如果你有好的意见或建议，欢迎给我们提 Issues 或 Pull Requests，为提升抓包调试体验贡献力量。\n[腾讯开源激励计划](https://opensource.tencent.com/contribution) 鼓励开发者的参与和贡献，期待你的加入。\n# License\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTencent%2Fnohost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FTencent%2Fnohost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FTencent%2Fnohost/lists"}