网关安装

网关

# 前提条件

  1. 拥有IDaaS企业中心平台的管理员权限。
  2. 已在IDaaS平台添加网关和网关Server。
  3. 拥有服务器的操作权限。
  4. 服务器可访问IDaaS服务。

# 安装Gateway

以下将介绍如何在Linux环境下完成对Gateway网关的服务安装和部署,为防止出现非预期问题,以下操作请使用root权限操作。

请确保网关部署服务器能够访问外网,或者至少能够访问IDaaS服务器,否则无法完成网关的安装和部署。

# 1. 建立运行目录

mkdir -p /opt/gateway
cd /opt/gateway
1
2

# 2. 下载并解压

# 下载最新网关
wget https://idaas-prod.oss-cn-zhangjiakou.aliyuncs.com/gateway/server/gateway-24.6.1.0.tar.gz

# 解压
tar -zxvf gateway-24.6.1.0.tar.gz

# 将网关二进制文件移动到/usr/bin目录下,方便执行gateway命令
mv -f gateway-24.6.1.0/gateway /usr/bin

# 测试,成功将会输出当前网关版本号
gateway version

# 删除压缩包(非必须)
rm -rf gateway-24.6.1.0.tar.gz
1
2
3
4
5
6
7
8
9
10
11
12
13
14

# 连接IDaaS并启动

## 移动配置文件到当前目录(当前目录为/opt/gateway)
mv gateway-24.6.1.0/config /opt/gateway/

## 编辑配置文件
vim config/idaas.json

## 完成配置后,执行以下命令安装网关服务
gateway service install --idaas-config=/opt/gateway/config/idaas.json

## 启动网关服务
gateway service start

## 查看服务日志
journalctl -u GatewayServer -f

## 删除无效的文件夹(非必须)
rm -rf gateway-24.6.1.0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

  • 配置文件请根据IDaaS创建网关Server时提供的配置信息进行配置
  • 网关服务安装成功后,系统服务会创建一个GatewayServer服务。 (安装成功自动生成文件/etc/systemd/system/GatewayServer.service)

# 验证网关服务

  • 通过查看IDaaS的应用安全网关Server列表,如网关服务状态为在线,恭喜你完成网关的安装和部署
  • 后续可通过网关指南完成应用的配置和使用

# 网关命令介绍

  1. gateway [command] --help 可查看命令帮助信息
Gateway is an extensible server platform written in Go.

Usage:
  gateway [command]

Examples:
  $ gateway run --config config/gateway.json
  $ gateway run --idaas-config config/idaas.json
  $ gateway service


Available Commands:
  encrypt     Provide encryption tools, Used to encrypt configuration parameters
  generate    Automatically generate relevant data
  help        Help about any command
  run         Run the Gateway process and blocks indefinitely
  service     Administration Gateway Server System service, Administrator privileges are required to execute this Subcommands
  version     Prints gateway server version

Flags:
  -h, --help   help for gateway

Use "gateway [command] --help" for more information about a command.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
  1. gateway run [flags] --help 运行网关

通过run命令执行程序,当终端关闭时,程序会自动退出,如果需要后台执行gateway程序,可以通过nohup命令。 也可以使用gateway网关支持的service命令实现网关服务管理,能够完美解决应用程序后台运行,并随系统启动而启动

Run the Gateway process and blocks indefinitely

Usage:
gateway run [flags]

Flags:
--config string         Gateway Configuration file, default config/gateway.json
-h, --help                  help for run
--idaas-config string   IDaaS Configuration file, default config/idaas.json
1
2
3
4
5
6
7
8
9
  1. gateway service [command] --help 网关服务操作命令
Administration Gateway Server System service, Administrator privileges are required to execute this Subcommands

Usage:
  gateway service [command]

Available Commands:
  install     install Gateway Server System service, specify config file (use --config)
  restart     restart Gateway Server System service
  start       start Gateway Server System service
  status      view Gateway Server System service status
  stop        stop Gateway Server System service
  uninstall   uninstall Gateway Server System service

Flags:
  -h, --help   help for service

Use "gateway service [command] --help" for more information about a command.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17