apisix admin api 403 Forbidden(接口请求403)

故事背景

当你通过admin api 接口方式执行相关操作时,例如route、upstream设置,接口返回403 Forbidden,

例如 请求

curl -i "http://192.168.100.1:9180/apisix/admin/routes" -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '

{

"id": "getting-started-headers",

"uri": "/headers",

"upstream" : {

"type": "roundrobin",

"nodes": {

"httpbin.org:443": 1,

"mock.api7.ai:443": 1

},

"pass_host": "node",

"scheme": "https"

}

}'

返回结果:

<html>

<head>

<title>403 Forbidden</title>

</head>

<body>

<center>

<h1>403 Forbidden</h1>

</center>

<hr>

<center>openresty</center>

<p><em>Powered by <a href="https://apisix.apache.org/">APISIX</a>.</em></p>

</body>

</html>

原因分析

造成403 Forbidden的原因是,apisix处于安全考虑,默认只允许apisix本机访问调用api

解决方法

  1. 找到apisix配置文件,通常在/usr/local/apisix/conf/config-default.yaml
  2. 修改如下配置信息,如下图所示,最好先备份一份,再修改
  3. 修改完成后,重启apisix,即可生效
  4. 注释掉这个配置代表所有人都可以访问,因此为了安全考虑,你指定某些ip更优
相关推荐
TracyCoder12313 天前
APISIX 简介:云原生 API 网关的架构与实践
云原生·架构·apisix
保持学习ing20 天前
微服务--Gateway网关
java·网关·微服务·gateway
半路_出家ren20 天前
第六章网络互联设备
网络·网关·交换机·中继器·集线器·网桥·无线ap
小白爱电脑1 个月前
路由器、网关和光猫三种设备有啥区别?
运维·网络·网关·路由器·光猫
开挖掘机上班1 个月前
常见的网络设备
网络·网关·智能路由器·路由器·交换机
JIANGHONGZN1 个月前
DeviceNET转EtherCAT网关:医院药房自动化的智能升级神经中枢
网关·工业自动化·ethercat·协议网关·工业通讯·devicenet
深圳市尚想信息技术有限公司2 个月前
智能家居“心脏“升级战:GD25Q127CSIG国产芯片如何重构家庭物联生态
网关·智能家居·存储芯片·兆易创新·闪存芯片
jakeswang3 个月前
Higress: 阿里巴巴高性能云原生API网关详解
网关·架构
衣舞晨风3 个月前
Apache APISIX 架构浅析
架构·apache·openresty·apisix
Code额3 个月前
微服务的网关配置
网关·微服务·架构