Cuicheng's 博客

日啖荔枝三百颗 不辞长作岭南人

0%

kong 网关基础内容

script
1
2
# 最新安装包位置
https://kong.bintray.com/kong-community-edition-rpm/centos/7/
script
1
yum install -y https://kong.bintray.com/kong-community-edition-rpm/centos/7/kong-community-edition-1.1.2.el7.noarch.rpm
script
1
2
# 前王该地址获取最新包
https://yum.postgresql.org/repopackages/
script
1
yum install postgresql13-contrib postgresql13-server -y
script
1
2
3
4
5
6
# 安装
/usr/pgsql-13/bin/postgresql-13-setup initdb
vim /var/lib/pgsql/13/data/postgresql.conf
vim /var/lib/pgsql/13/data/pg_hba.conf
# 修改 listen_addresses
sed -i /^listen_addresses/c\listen_addresses=\'*\' /var/lib/pgsql/13/data postgresql.conf
script
1
2
# pg 查询用户
select rolname,rolpassword from pg_authid;
script
1
2
3
4
5
6
7
8
9
10
11
su - postgres << EOF

psql << XOF

CREATE USER kong;
CREATE DATABASE kong OWNER kong;
ALTER USER kong PASSWORD 'Kong@123';

XOF

EOF
script
1
2
# 修改pg密码
\password role
script
1
2
3
4
5
6
# kong docker 安装地址
https://docs.konghq.com/install/docker/
# 配置修改
vim /etc/kong/kong.conf

kong
script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
docker run -d --name kong \
--network=kong-net \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_USER=kong" \
-e "KONG_PG_PASSWORD=kong" \
-e "KONG_CASSANDRA_CONTACT_POINTS=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 8000:8000 \
-p 8443:8443 \
-p 10.0.0.22:8001:8001 \
-p 10.0.0.22:8444:8444 \
kong:latest
script
1
2
3
4
curl -i -X POST \
--url http://10.0.0.22:8001/services/ \
--data 'name=actifio-service' \
--data 'url=https://10.0.0.6'
script
1
2
3
curl -i -X POST \
--url http://10.0.0.22:8001/services/actifio-service/routes \
--data 'hosts[]=activeio.com.cn'
script
1
2
3
curl -i -X GET \
--url http://10.0.0.22:8000/ \
--header 'Host: activeio.com.cn'