1、前提条件:
安装docker
检查docker状态
systemctl status docker
2、安装higress
安装时顺便配置nacos地址:
curl -fsSL https://higress.io/standalone/get-higress.sh | bash -s -- -c nacos://10.51.3.118:8848
或者安装时可配置nacos的账号密码,管理登录初始密码:123456
curl -fsSL https://higress.io/standalone/get-higress.sh | bash -s -- -c nacos://10.51.3.118:8848 --nacos-username=nacos --nacos-password=nacos -p nacos
curl -fsSL https://higress.io/standalone/get-higress.sh | bash -s -- -c nacos://10.51.3.118:8848 --nacos-username=nacos --nacos-password=nacos
如果报错
docker: 'compose' is not a docker command.
需要先安装compose
#下载docker-compose文件
https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-x86_64
#将文件复制到/usr/local/bin环境变量下面
上传到目录:/usr/local/bin
执行命令:mv docker-compose-linux-x86_64 docker-compose
赋权:chmod 755 docker-compose
#查看版本
docker-compose -version
进入到higress 的目录下
cd /root/higress/bin
修改下nacos的地址
执行命令配置(可以不去配置,上面有初始化的话) ./configure.sh -r -c nacos://10.51.3.118:8848 执行后有管理的账号密码,要记下这个账号密码,登录管理页面时候用到
启动Higress
./startup.sh
登录higress管理页面
higress的默认端口是8080 地址:http://ip:8080/ 注:如果 已有服务运行端口为8080,则会端口占用,需要修改下higress的默认端口映射 由于基于 Docker Compose 设计的,进入到higress目录下的compose中, 修改文件配置:docker-compose.yml 这里将原来的8080 改成了8083 回到higress目录下的bin,执行启动脚本即可:./startup.sh 访问页面:http://ip:8083/ 账号密码:admin/39ddf0d9a7f2483ed2d9cb1bfedab896
先配置服务来源
配置证书(HTTP的不配也行)
配置域名
配置路由
给这个路由增加了一个重写的策略,就是由请求路径预实际的接口路径不一致,
通过当前的请求到网关,再重写到实际接口地址中去,实现所有接口先经过网关再到真实接口
postman测试
项目实际地址:https://域名:端口/core/api/v1/open/login/getLoginPage.json?url=ot.com postman请求地址:https://域名:9443/test/api/pc/v1/api/login/getLoginPage.json?url=ot.com https://域名:9443,这个是网关部署的地址,9443端口负载到了网关服务器的80端口或者443端口都行(这个要做,不然到不了网关应用) 简单来说就是:/test/api/pc/v1/api/ 转发到目标的/core/api/v1/open/
记录安装过程中的端口
Please input the local HTTP port to access the built-in Nacos [8848]: 8848
Please input the local HTTP port to access Higress Gateway [80]: 8083
Please input the local HTTPS port to access Higress Gateway [443]: 443
Please input the local metrics port to be listened by Higress Gateway [15020]: 15020
Please input the local port to access Higress Console [8080]: 8084