APISIX 修改默认9080和9443端口号

释放双眼,带上耳机,听听看~!
🤖 由 ChatGPT 生成的文章摘要

默认情况下apisix使用9080和9443当作服务入口,我们在非容器的时候可能会使用80和443端口。接下来我们修改apisix配置文件,开启80和443端口

这里以apisix-docker为例

我这里版本为3.2.2,apisix版本号不同修改的参数配置也不相同

首先修改apisix/conf/conf.yml文件

root@frps:~/apisix-docker# vim example/apisix_conf/config.yaml

修改http 80端口

apisix:
  node_listen:
    - 9080
    - 80

修改https 443端口

apisix:
  ssl:
    enable: true
    listen:
      - port: 443

apisix完整配置文件如下

apisix:
  node_listen:
    - 9080
    - 80
  ssl:
    enable: true
    listen:
      - port: 443
  enable_ipv6: false

  enable_control: true
  control:
    ip: "0.0.0.0"
    port: 9092

deployment:
  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: edaacccc3vvvv3bbb5f136f87ad84b625c8f1
        role: admin                 # admin: manage all configuration data

      - name: "viewer"
        key: 4054f7cf07e344346cd3f287985e76a2
        role: viewer

  etcd:
    host:                           # it's possible to define multiple etcd hosts addresses of the same etcd cluster.
      - "http://etcd:2379"          # multiple etcd address
    prefix: "/apisix"               # apisix configurations prefix
    timeout: 30                     # 30 seconds

plugin_attr:
  prometheus:
    export_addr:
      ip: "0.0.0.0"
      port: 9091

接下来需要修改docker-compose.yml,将80和443端口映射出来

version: "3"

services:
  apisix-dashboard:
    image: apache/apisix-dashboard:3.0.1-alpine
    restart: always
    volumes:
    - ./dashboard_conf/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml
    ports:
    - "9000:9000"
    networks:
      apisix:

  apisix:
    image: apache/apisix:${APISIX_IMAGE_TAG:-3.2.2-debian}
    restart: always
    volumes:
      - ./apisix_conf/config.yaml:/usr/local/apisix/conf/config.yaml:ro
    depends_on:
      - etcd
    ##network_mode: host
    ports:
      - "9180:9180/tcp"
      - "9080:9080/tcp"
      - "9091:9091/tcp"
      - "9443:9443/tcp"
      - "9092:9092/tcp"
      - "80:80/tcp"                    #此处开启80
      - "443:443/tcp"                   #此处开启映射443
    networks:
      apisix:
     ...
     ...

最终效果

APISIX 修改默认9080和9443端口号

给TA打赏
共{{data.count}}人
人已打赏
APISIX报错锦集

APISIX runtime error: /usr/local/apisix/apisix/init.lua:332: attempt to index local 'matched_ssl' (a nil value)

2023-8-22 0:30:39

APISIXDockerKubernetes

Docker快速部署APISIX代替Nginx

2023-9-14 16:37:46

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索