Kong 服务和路由的添加

管理服务

这里参考DB-less-Mode,因为使用的是yaml配置文件的形式,所以所有的相关配置只需要往初始化的kong.yml文件中添加就可以了,就像nginx的配置文件

DB-less-Mode

创建服务

vim /etc/kong/kong.yml

yaml 复制代码
services:
- name: my-service  # 服务名称
  url: localhost:8801  # 这里填写backend服务地址
  tags:
   - test-service
  routes:
  - name: ngrok-mep-server  # 路由名称
    paths:
    - /test-service  # 路由后缀名称


# 下面是初始化的建议配置
 services:
 - name: example-service
   url: http://example.com
   # Entities can store tags as metadata
   tags:
   - example
   # Entities that have a foreign-key relationship can be nested:
   routes:
   - name: example-route
     paths:
     - /
   plugins:
   - name: key-auth
 - name: another-service
   url: https://example.org

检查文件

shell 复制代码
kong config -c kong.conf parse kong.yml

Response:

复制代码
parse successful

加载文件

复制代码
kong start -c kong.conf
已启动的使用
kong restart -c kong.conf

校验服务是否正常

我们可以在kong的8000端口后加上路由后缀/test-service查看服务是否正常

复制代码
curl -i localhost:8000/test-service

这里由于项目路径原因显示404,但其实后端已经收到请求了

相关推荐
青莲网络22 分钟前
安全第一与合规治理:魔芋 AI 正式发布企业级大模型网关 Mai Gateway
人工智能·安全·gateway
爱吃羊的老虎1 小时前
【JAVA】Java微服务—网关Gateway
java·微服务·gateway
小悟空5 小时前
[AI 生成] Nginx 502 Bad Gateway 排查手册(Python 后端篇)
python·nginx·gateway
小马爱打代码5 小时前
SpringBoot + SpringCloud Gateway + Sentinel + Redis:API 网关层的接口限流、黑名单拦截与用户认证
spring boot·spring cloud·gateway
Waay1 天前
从 0 到 1 实操 K8s Gateway API+Istio:告别 Ingress,用新标准实现域名访问
kubernetes·gateway·istio
AOwhisky4 天前
Ceph系列第五期:Ceph 对象存储(RADOS Gateway)精讲
linux·运维·笔记·ceph·gateway·对象存储
西凉的悲伤5 天前
Spring Cloud Gateway介绍
java·spring cloud·gateway
苏渡苇6 天前
Spring Cloud Gateway 网关限流
spring cloud·gateway·springboot·网关限流
一个儒雅随和的男子7 天前
Spring cloud组件gateway网关详细剖析
spring·spring cloud·gateway
超梦dasgg7 天前
Gateway 鉴权场景:网关统一鉴权 + 业务应用决定放行规则
java·gateway