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,但其实后端已经收到请求了

相关推荐
疯狂的维修3 天前
关于Gateway configration studio软件配置网关
网络协议·c#·自动化·gateway
hadage2333 天前
--- 统一请求入口 Gateway ---
gateway
波波烤鸭5 天前
深入理解 Gateway 网关:原理、源码解析与最佳实践
java·spring·gateway
DO_Community5 天前
DigitalOcean Kubernetes 现已支持 Gateway API 托管服务
容器·kubernetes·gateway
T_Ghost5 天前
SpringCloud微服务网关Gateway
spring cloud·微服务·gateway
Rysxt_7 天前
Spring Boot Gateway 教程:从入门到精通
spring boot·网关·gateway
月夕·花晨7 天前
Gateway -网关
java·服务器·分布式·后端·spring cloud·微服务·gateway
sanggou7 天前
License 集成 Spring Gateway:解决 WebFlux 非阻塞与 Spring MVC Servlet 阻塞兼容问题
spring·gateway·mvc
摘星编程13 天前
Nginx 502 Bad Gateway:从 upstream 日志到 FastCGI 超时复盘
网络·nginx·gateway·php-fpm·fastcgi
网硕互联的小客服13 天前
504 Gateway Timeout:服务器作为网关或代理时未能及时获得响应如何处理?
运维·服务器·gateway