apisix request help: 路由设置失败,希望通过访问apisix最终路由到10.101.42.163:8082/user/hello这个地址 - Lua

路由设置访问失败

10.101.42.163 服务器上面部署web应用 ,地址10.101.42.163:8082/user/hello 10.255.249.3上面部署的是apisix 创建Route如下:

{
    "uri": "/user/hello",
    "upstream": {
        "type": "roundrobin",
        "nodes": {
            "10.101.42.163:8082": 1
        }
    }
}

配置UpStream如下:

{
  "type": "roundrobin",
  "nodes": {
    "10.101.42.163:8082": 1
  }
}

路由上游绑定如下:

{
    "uri": "/user/hello",
    "upstream_id": upstreamid
}

访问

10.255.249.3:9080/user/hello 无响应,没有正确的路由到 10.101.42.163:8082/user/hello这个地址上来,请帮忙指点一下

  • apisix version (cmd: apisix version): 2.5
  • OS (cmd: uname -a): Linux csf-2 3.10.0-693.el7.x8664 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x8664 x8664 x8664 GNU/Linux
  • OpenResty / Nginx version (cmd: nginx -V or openresty -V): nginx/1.16.1
  • etcd version, if have (cmd: run curl http://127.0.0.1:9090/v1/server_info to get the info from server-info API): 3.4.0
  • apisix-dashboard version, if have: 2.5
  • luarocks version, if the issue is about installation (cmd: luarocks --version): 3.4.0
Asked Oct 20 '21 18:10
avatar vincentwc
vincentwc

2 Answer:

You can directly create a route for proxy access like this:

curl http://127.0.0.1:9280/apisix/admin/routes/1  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "uri": "/user/hello",    
    "upstream": {
        "type": "roundrobin",
        "nodes": {
            "10.101.42.163:8082": 1
        }
    }
}'
curl http://10.255.249.3:9080/user/hello

This way you don't have to create upstream objects separately.

1
Answered May 12 '21 at 01:42
avatar  of Firstsawyou
Firstsawyou

check and find my server firewall is on state,so can't redirect to myu local computer

1
Answered May 12 '21 at 06:52
avatar  of vincentwc
vincentwc