在Azure VM上部署Apixix并在路由到应用服务时收到404错误

siv3szwd  于 2022-12-24  发布在  其他
关注(0)|答案(1)|浏览(384)

我在虚拟机和应用程序服务上都使用了私有端点。在虚拟机控制台中,使用域时可以工作,但使用私有IP时失败。

$ curl https://myAppService..azurewebsites.net
{"result":"Hello World","code":200,"success":true}

$ curl http://10.0.5.5
....
<h1>404 Web Site not found.</h1>
            <p>You may be seeing this error due to one of the reasons listed below :</p>
....

到目前为止,我可以理解它。但是,我设置了apisix路由配置如下,并得到404错误以及。

{
  "uri": "/test/*",
  "name": "test",
  "methods": [
    "GET",
    "POST",
    "PUT",
    "DELETE",
    "PATCH",
    "HEAD",
    "OPTIONS",
    "CONNECT",
    "TRACE",
    "PURGE"
  ],
  "plugins": {
    "cors": {
      "allow_credential": false,
      "allow_headers": "*",
      "allow_methods": "*",
      "allow_origins": "*",
      "disable": false,
      "expose_headers": "*",
      "max_age": 5
    },
    "proxy-rewrite": {
      "uri": "/"
    }
  },
  "upstream": {
    "nodes": [                             <--------- Here
      {
        "host": "myAppService.azurewebsites.net",
        "port": 443,
        "weight": 1
      }
    ],
    "retries": 3,
    "timeout": {
      "connect": 6,
      "send": 6,
      "read": 6
    },
    "type": "roundrobin",
    "scheme": "https",
    "pass_host": "pass",
    "keepalive_pool": {
      "idle_timeout": 60,
      "requests": 1000,
      "size": 320
    }
  },
  "status": 1
}

在我检查了access.log之后,我发现网关解析了主机,并使用ip(10.0.5.5)路由请求。

[14/Dec/2022:11:00:15 +0000] 20.212.162.118 "GET /test/123 HTTP/1.1" 404 2667 0.012 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Edg/108.0.1462.46" 10.0.5.5:443 404 0.012

有什么建议吗?
1.使用应用网关
1.将Apixx部署到ACI。但是我们的一些服务不被认为是容器化的。
我想按正常路线行驶...

41zrol4v

41zrol4v1#

在我弄清楚这个问题与Nginx有关后,我终于找到了答案。
由于应用程序请求路由亲和性(ARR),需要将主机名设置为“使用节点列表中的域名或IP”。因此,Apixx不会解析主机名,例如*.auzrewebsits.net10.0.x.x,而ARR工作正常。x1c 0d1x
万岁!

相关问题