# gateway **Repository Path**: jaasdsa/gateway ## Basic Information - **Project Name**: gateway - **Description**: 接口网关 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-31 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # nginx 实现interface网关服务 --- - 对外根据客户端IP并发限流,对内白名单模式 - 对外加入用户名和密码实现权限认证 ## 初始化运行环境 - 安装node ,可tools选择对应版本安装 - 切换到淘宝源 ```bash npm config set registry https://registry.npm.taobao.org npm install nrm -g nrm ls nrm use taobao nrm current ``` - 安装`node进程守护`工具 ```bash npm i pm2 pm2-windows-service -g ``` ## 安装网关服务 - 以`管理员身份`运行 `deploy`目录下`安装服务.bat` - 安装完成后在`services.msc`目录下会多出`PandaCityInterfaceGateway`服务和`PandaCityInterfaceAuthorization` - `PandaCityInterfaceGateway`为`nginx进程守护`服务,并对外提供网关服务 - `PandaCityInterfaceAuthorization` 为`认证接口`服务,nginx内部做用户认证使用 ## 卸载网关服务 - 以`管理员身份`运行 `deploy`目录下`卸载服务.bat` ## 启动服务 - 手动启动服务,以`管理员身份`运行 `deploy`目录下`start.bat` - 自动启动服务,重启计算机即可 ## node的应用做成windows服务 - 安装pkg打包工具 ```bash npm install -g pkg ``` - package.json配置打包命令 ```bash "scripts": { "build": "pkg ./src/index.js -t win --output app.exe" #--t win 只打包windows应用 } ``` - 解决首次需要下载node源码 1. 找到当前用户home文件夹,windows一般为`C:\Users\用户名` 2. 在home文件夹里找到`.pkg-cache/v2.6` 文件夹 (具体以当前有v2.x文件夹为主) 3. 下载对应系统对应版本(版本可相差不大)的[node二进制文件](https://github.com/vercel/pkg-fetch/releases) 4. 将第三步下载的文件移动到第二步的文件夹(将第二步的文件夹`.pkg-cache/v2.6`里的文件先删除完) 5. 将移动后的文件重命名为`fetched-v10.xx.x-win-x64`(具体参考第三步下载的版本名) 6. 重新打包(不在下载包视为成功)