Ubuntu部署开源网关Apache APISIX

2024-06-07 03:28

本文主要是介绍Ubuntu部署开源网关Apache APISIX,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

说明

  • 系统:Ubuntu 24.04 LTS
  • Docker版本:v26.1.3
  • Docker Compose版本:v2.26.1

下载和配置

Ubuntu需要安装Docker和Docker Compose

下载apisix-docker仓库

git clone https://github.com/apache/apisix-docker.git

修改docker-compose

在这里插入图片描述

配置etcd会用到IP。查看本机ip,获取到IP地址为“192.168.8.249”

ip addr show
root@vinci:~/apisix-docker/example# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope hostvalid_lft forever preferred_lft forever
2: ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000link/ether bc:24:11:64:57:05 brd ff:ff:ff:ff:ff:ffaltname enp0s18inet 192.168.8.249/24 metric 100 brd 192.168.8.255 scope global dynamic ens18valid_lft 42804sec preferred_lft 42804secinet6 fe80::be24:11ff:fe64:5705/64 scope linkvalid_lft forever preferred_lft forever
3: br-ba3ee5d501df: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group defaultlink/ether 02:42:0e:b1:ea:76 brd ff:ff:ff:ff:ff:ffinet 172.18.0.1/16 brd 172.18.255.255 scope global br-ba3ee5d501dfvalid_lft forever preferred_lft forever
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group defaultlink/ether 02:42:d8:18:f9:c7 brd ff:ff:ff:ff:ff:ffinet 172.17.0.1/16 brd 172.17.255.255 scope global docker0valid_lft forever preferred_lft forever

修改docker-compose.yml,主要修改如下

...etcd:...environment:...ETCD_ADVERTISE_CLIENT_URLS: "http://192.168.8.249:2379"
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#version: "3"services:apisix:image: apache/apisix:${APISIX_IMAGE_TAG:-3.9.0-debian}restart: alwaysvolumes:- ./apisix_conf/config.yaml:/usr/local/apisix/conf/config.yaml:rodepends_on:- etcd##network_mode: hostports:- "9180:9180/tcp"- "9080:9080/tcp"- "9091:9091/tcp"- "9443:9443/tcp"- "9092:9092/tcp"networks:apisix:etcd:image: bitnami/etcd:3.5.11restart: alwaysvolumes:- etcd_data:/bitnami/etcdenvironment:ETCD_ENABLE_V2: "true"ALLOW_NONE_AUTHENTICATION: "yes"ETCD_ADVERTISE_CLIENT_URLS: "http://192.168.8.249:2379"ETCD_LISTEN_CLIENT_URLS: "http://0.0.0.0:2379"ports:- "2379:2379/tcp"networks:apisix:web1:image: nginx:1.19.0-alpinerestart: alwaysvolumes:- ./upstream/web1.conf:/etc/nginx/nginx.confports:- "9081:80/tcp"environment:- NGINX_PORT=80networks:apisix:web2:image: nginx:1.19.0-alpinerestart: alwaysvolumes:- ./upstream/web2.conf:/etc/nginx/nginx.confports:- "9082:80/tcp"environment:- NGINX_PORT=80networks:apisix:prometheus:image: prom/prometheus:v2.25.0restart: alwaysvolumes:- ./prometheus_conf/prometheus.yml:/etc/prometheus/prometheus.ymlports:- "9090:9090"networks:apisix:grafana:image: grafana/grafana:7.3.7restart: alwaysports:- "3000:3000"volumes:- "./grafana_conf/provisioning:/etc/grafana/provisioning"- "./grafana_conf/dashboards:/var/lib/grafana/dashboards"- "./grafana_conf/config/grafana.ini:/etc/grafana/grafana.ini"networks:apisix:networks:apisix:driver: bridgevolumes:etcd_data:driver: local

更新Admin API key

建议修改Admin API的key,保护APISIX的安全

在这里插入图片描述

修改config.yaml,主要修改key值和host的IP

...admin_key:- name: "admin"key: edc1c9f034335f136f87ad84b625c8f1role: admin                 # admin: manage all configuration data...etcd:host:                           # it's possible to define multiple etcd hosts addresses of the same etcd cluster.- "http://192.168.8.249:2379"          # multiple etcd address...
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#apisix:node_listen: 9080              # APISIX listening portenable_ipv6: falseenable_control: truecontrol:ip: "0.0.0.0"port: 9092deployment:admin:allow_admin:               # https://nginx.org/en/docs/http/ngx_http_access_module.html#allow- 0.0.0.0/0              # We need to restrict ip access rules for security. 0.0.0.0/0 is for test.admin_key:- name: "admin"key: edc1c9f034335f136f87ad84b625c8f1role: admin                 # admin: manage all configuration data- name: "viewer"key: 4054f7cf07e344346cd3f287985e76a2role: vieweretcd:host:                           # it's possible to define multiple etcd hosts addresses of the same etcd cluster.- "http://192.168.8.249:2379"          # multiple etcd addressprefix: "/apisix"               # apisix configurations prefixtimeout: 30                     # 30 secondsplugin_attr:prometheus:export_addr:ip: "0.0.0.0"port: 9091

启动服务

使用docker-compose​启用APISIX

docker-compose -p docker-apisix up -d

在这里插入图片描述

查看状态

docker stats

在这里插入图片描述

验证etcd,浏览器打开http://192.168.8.249:2379/version​,显示如下

{"etcdserver": "3.5.11","etcdcluster": "3.5.0"
}

安装Apache APISIX Dashboard

sudo mkdir -p /usr/apisix-dashboard/conf
sudo vim /usr/apisix-dashboard/conf/conf.yaml

conf.yaml文件如下。endpoints里的IP地址改为192.168.8.249,username为登录用户名,password为登录密码

conf:listen:host: 0.0.0.0   # the address on which the `Manager API` should listen.# The default value is 0.0.0.0, if want to specify, please enable it.# This value accepts IPv4, IPv6, and hostname.port: 9000      # The port on which the `Manager API` should listen.allow_list:       # If we don't set any IP list, then any IP access is allowed by default.etcd:endpoints:      # supports defining multiple etcd host addresses for an etcd cluster- 192.168.8.249:2379 # etcd install ip
authentication:secret:zQ5w5jkLDh3jZpywJ3sskrw6Yv633ruqexpire_time: 3600     # jwt token expire time, in secondusers:                # yamllint enable rule:comments-indentation- username: admin       # dashboard login infomationpassword: 123456- username: userpassword: 123456
docker pull apache/apisix-dashboard:3.0.1-alpinedocker run -d --name dashboard \-p 9000:9000        \-v /usr/apisix-dashboard/conf/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml \apache/apisix-dashboard:3.0.1-alpine

浏览器打开“http://192.168.8.249:9000/”,输入用户名和密码登录

在这里插入图片描述

参考

  • APISIX 安装指南 | Apache APISIX® – Cloud-Native API Gateway

这篇关于Ubuntu部署开源网关Apache APISIX的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1038036

相关文章

SpringBoot中整合RabbitMQ(测试+部署上线最新完整)的过程

《SpringBoot中整合RabbitMQ(测试+部署上线最新完整)的过程》本文详细介绍了如何在虚拟机和宝塔面板中安装RabbitMQ,并使用Java代码实现消息的发送和接收,通过异步通讯,可以优化... 目录一、RabbitMQ安装二、启动RabbitMQ三、javascript编写Java代码1、引入

Debezium 与 Apache Kafka 的集成方式步骤详解

《Debezium与ApacheKafka的集成方式步骤详解》本文详细介绍了如何将Debezium与ApacheKafka集成,包括集成概述、步骤、注意事项等,通过KafkaConnect,D... 目录一、集成概述二、集成步骤1. 准备 Kafka 环境2. 配置 Kafka Connect3. 安装 D

ElasticSearch+Kibana通过Docker部署到Linux服务器中操作方法

《ElasticSearch+Kibana通过Docker部署到Linux服务器中操作方法》本文介绍了Elasticsearch的基本概念,包括文档和字段、索引和映射,还详细描述了如何通过Docker... 目录1、ElasticSearch概念2、ElasticSearch、Kibana和IK分词器部署

部署Vue项目到服务器后404错误的原因及解决方案

《部署Vue项目到服务器后404错误的原因及解决方案》文章介绍了Vue项目部署步骤以及404错误的解决方案,部署步骤包括构建项目、上传文件、配置Web服务器、重启Nginx和访问域名,404错误通常是... 目录一、vue项目部署步骤二、404错误原因及解决方案错误场景原因分析解决方案一、Vue项目部署步骤

Linux流媒体服务器部署流程

《Linux流媒体服务器部署流程》文章详细介绍了流媒体服务器的部署步骤,包括更新系统、安装依赖组件、编译安装Nginx和RTMP模块、配置Nginx和FFmpeg,以及测试流媒体服务器的搭建... 目录流媒体服务器部署部署安装1.更新系统2.安装依赖组件3.解压4.编译安装(添加RTMP和openssl模块

0基础租个硬件玩deepseek,蓝耘元生代智算云|本地部署DeepSeek R1模型的操作流程

《0基础租个硬件玩deepseek,蓝耘元生代智算云|本地部署DeepSeekR1模型的操作流程》DeepSeekR1模型凭借其强大的自然语言处理能力,在未来具有广阔的应用前景,有望在多个领域发... 目录0基础租个硬件玩deepseek,蓝耘元生代智算云|本地部署DeepSeek R1模型,3步搞定一个应

Ubuntu固定虚拟机ip地址的方法教程

《Ubuntu固定虚拟机ip地址的方法教程》本文详细介绍了如何在Ubuntu虚拟机中固定IP地址,包括检查和编辑`/etc/apt/sources.list`文件、更新网络配置文件以及使用Networ... 1、由于虚拟机网络是桥接,所以ip地址会不停地变化,接下来我们就讲述ip如何固定 2、如果apt安

redis群集简单部署过程

《redis群集简单部署过程》文章介绍了Redis,一个高性能的键值存储系统,其支持多种数据结构和命令,它还讨论了Redis的服务器端架构、数据存储和获取、协议和命令、高可用性方案、缓存机制以及监控和... 目录Redis介绍1. 基本概念2. 服务器端3. 存储和获取数据4. 协议和命令5. 高可用性6.

Deepseek R1模型本地化部署+API接口调用详细教程(释放AI生产力)

《DeepseekR1模型本地化部署+API接口调用详细教程(释放AI生产力)》本文介绍了本地部署DeepSeekR1模型和通过API调用将其集成到VSCode中的过程,作者详细步骤展示了如何下载和... 目录前言一、deepseek R1模型与chatGPT o1系列模型对比二、本地部署步骤1.安装oll

nginx部署https网站的实现步骤(亲测)

《nginx部署https网站的实现步骤(亲测)》本文详细介绍了使用Nginx在保持与http服务兼容的情况下部署HTTPS,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值... 目录步骤 1:安装 Nginx步骤 2:获取 SSL 证书步骤 3:手动配置 Nginx步骤 4:测