API网关Kong
各种方式安装汇总:https://konghq.com/install/
命令列表:https://docs.konghq.com/0.14.x/admin-api/
官方插件列表:https://docs.konghq.com/hub/
相关学习笔记链接:https://www.lijiaocn.com/%E9%A1%B9%E7%9B%AE/2018/09/29/nginx-openresty-kong.html
相关博客:https://www.itcodemonkey.com/article/5980.html
Kong集群搭建博客:https://www.cnblogs.com/zhoujie/p/kong6.html
github:https://github.com/Kong
可视化程序dashboard github:https://github.com/PGBI/kong-dashboard
缓存插件github:https://github.com/globocom/kong-plugin-proxy-cache
kong配置文件默认地址:/etc/kong/kong.conf
kong插件默认地址:/usr/local/share/lua/5.1/kong/plugins
添加新插件时安装后需要在kong.conf中配置引入,proxy-cache插件安装前需要 luarocks install lua-resty-redis-connector
构建包含响应缓存插件的docker包:
Dockerfile:
From kong:latest RUN apk update
RUN apk add git
RUN luarocks install lua-resty-redis-connector
RUN luarocks install kong-plugin-proxy-cache
RUN cp /etc/kong/kong.conf.default /etc/kong/kong.conf
RUN echo "plugins = bundled, proxy-cache" >> /etc/kong/kong.conf EXPOSE 8000 8001 8443 8444
docker build -t custom-kong .
导出image:
docker save > kong.tar custom-kong:latest
导入image:
docker load < kong.tar
Kong集群(完全无状态):
主节点启动(与数据库在一个docker network):
docker run -d --name kong \
--network=kong-net \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
-e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
-e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
-p : \
-p : \
-p : \
-p : \
custom-kong:latest
其他节点:
docker run -d --name kong \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=10.95.55.185" \
-e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
-e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
-e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
-p : \
-p : \
-p : \
-p : \
custom-kong:latest
Kong集群前负载均衡nginx配置:
配置文件地址:/etc/nginx/nginx.conf
# include /...
upstream kongs {
server xx:xx:xx:xx:xx weight=;
server xx:xx:xx:xx:xx weight=;
}
# 修改http的请求头为源请求头
proxy_set_header Host $http_host;
proxy_set_header X-Forward-For $remote_addr; # 修改hearder支持加"_"
underscores_in_headers on;
server {
listen ;
server_name kongs;
location / {
proxy_pass http://kongs;
}
}
API网关Kong的更多相关文章
- API 网关 Kong
什么是 API 网关? 所谓网关,主要作用就是连接两个不同网络的设备,而今天所讲的 API 网关是指承接和分发客户端所有请求的网关层. 为什么需要网关层?最初是单体服务时,客户端发起的所有请求都可以直 ...
- Api网关Kong集成Consul做服务发现及在Asp.Net Core中的使用
写在前面 Api网关我们之前是用 .netcore写的 Ocelot的,使用后并没有完全达到我们的预期,花了些时间了解后觉得kong可能是个更合适的选择. 简单说下kong对比ocelot打动我的 ...
- API网关Kong系列(一)初识
最近工作需要,加上国内Kong的文章相对缺乏(搜来搜去就那么两篇文章),而且官方文档在某些demo上也有一些过时的地方,遂提笔记录下这些,希望能有帮助. 先随大流介绍下KONG(主要参考官网): 官方 ...
- API网关--Kong的实践
1. 什么是Kong 目前互联网后台架构一般是采用微服务,或者类似微服务的形式,应用的请求通常需要访问多个后台系统.如果让每一个后台系统都实现鉴权.限流.负载均衡.审计等基础功能是不合适的,通用的做法 ...
- API网关Kong系列(三)添加服务
进入之前部署好的kong-ui,默认第一次登陆需要配置kong服务的地址 进入API菜单,点击+号 按照要求填入相关信息 至此完成,可以使用诸如 https://your.domain.com:208 ...
- API网关Kong系列(二)部署
部署环境: [OS] centos 6.8(如果是centos6.5,请自行先升级到6.8,否则不支持docker) [Docker] Client version: 1.7.1 Client API ...
- API网关Kong部署和使用文档
KONG安装使用说明 系统版本:ubuntu14 1.下载安装包 $ wget https://github.com/Mashape/kong/releases/download/0.8.3/kong ...
- API网关——Kong实践分享
概述 01 什么是Kong Kong是一个在Nginx中运行的Lua应用程序,可以通过lua-nginx模块实现,Kong不是用这个模块编译Nginx,而是与OpenRestry一起发布,OpenRe ...
- API网关Kong系列(四)认证配置
目前根据业务需要先介绍2种认证插件:Key Authentication 及 HMAC-SHA1 认证 Key Authentication 向API添加密钥身份验证(也称为API密钥). 然后,消 ...
随机推荐
- JVM内存结构图表展示
1.理解的JVM内存结构 2.对于垃圾回收问题 垃圾的回收只在堆和永久区(方法区)中,因为对于线程而言,私有存储空间如栈.本地方法区.程序计数器等,会随着方法的加载完成而直接释放空间,因此不需要进行 ...
- 《C程序设计(第四版)》小记
我看的这本书很经典,它是谭浩强写的,也就是广为流传的“C语言红皮书”.在网上看了很多帖子,生活中也问过一些朋友,大多数人是不认可这本书的.很多人都说这本书很烂,看不懂,然后去“追逐”国外的一些教材.其 ...
- 安装 texlive
多系统使用texlive 中文latex 用xelatex 编译 只需要加入宏包 \usepackage[UTF8]{ctex} Rmarkdown 配置模版 $ cat _output.yaml b ...
- Win10卸载python总是提示error2503失败各种解决办法
最近win10的电脑装了python的3.4,然后想卸载,就总是提示error 2053,类似于这种: 下面是我的坎坷解决之路: 1.网上说,任务管理器 --> 详细信息 --> expl ...
- embed标签属性
embed标签属性 (一).基本语法: embed src=url 说明:embed可以用来插入各种多媒体,格式可以是 Midi.Wav.AIFF.AU.MP3等等, Netscape及新版 ...
- No module named 'dateutil'
pip3 install python-dateutil
- Django模型迁移提示版本不匹配解决办法
Django迁移模型时提示django.core.exceptions.ImproperlyConfigured:mysqlclient 1.3.7 or newer is required; you ...
- 类似postman插件
Talend API Tester - Free Edition https://chrome.google.com/webstore/detail/talend-api-tester-free-ed ...
- SimpleDateFormat 线程安全的解决方案--DateTimeFormatter
SimpleDateFormat并不是线程安全的,因为在SimpleDateFormat中持有一个Calendar类对象在Parse 和Format方法时会调用calendar.setTime(dat ...
- Office Shared-Addin : Favorite的下载、安装和使用(2020.2.22)
Favorite是一个可以用于Office常用组件.VBA的共用加载项,32位和64位都兼容. 如果是Office 2007及其以上版本,界面显示为Custom UI+任务窗格. 如果是Office ...