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更优
相关推荐
疆鸿智能研发小助手1 天前
疆鸿智能 EtherNet/IP转ETHERCAT网关:打通罗克韦尔与汇川伺服的石材产线
网关·以太网·工业自动化·ethercat·ethernet ip·工业通讯·协议转换网关
peixiuhui1 天前
EdgeGateway 快速开始手册-OPUCA 服务器
mqtt·网关·modbus·iotgateway·边缘计算网关·edgegateway·opuca
peixiuhui1 天前
EdgeGateway 快速开始手册-串口服务器
运维·人工智能·网关·边缘计算·工业控制·串口服务器·iotgateway
peixiuhui1 天前
EdgeGateway 快速开始手册-常见问题
mqtt·网关·yolo·modbus·边缘计算网关·edgegateway·开源网关程序
peixiuhui5 天前
Iotgateway技术手册-6. 数据流程
网关·iot·iotgateway·开源网关·采集软件·开源mqtt·开源modbus
peixiuhui5 天前
Iotgateway技术手册-1. 项目概述
linux·网关·iot·modbus·数据采集网关·iotgateway·采集软件
peixiuhui5 天前
Iotgateway技术手册-10. 开发指南
物联网·网关·开源软件·iot·iotgateway·开源网关
peixiuhui5 天前
Iotgateway技术手册-5. 插件化驱动架构
开发语言·物联网·网关·数据采集·iot·dotnet·iotgateway
peixiuhui5 天前
Iotgateway技术手册-9. 部署与运行
网关·开源软件·iotgateway·开源网关·mqtt开源·开源dotnet
疆鸿智能研发小助手5 天前
工业网络协议网关在危化品生产自动化中的关键作用:以ETHERNET/IP转EtherCAT为例
网关·工业自动化·ethercat·ethernet ip·工业通讯·协议转换网关·机械手臂