apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.32k stars 2.49k forks source link

help request: The nginx config is converted to apisix conifg #11593

Open bestjane opened 1 day ago

bestjane commented 1 day ago

Description

  upstream gateway {
    server 127.0.0.1:3001;
  }

 server {

    listen 8888;
    server_name test.com;

    location / {
      proxy_set_header  Host                $host;
      proxy_pass        http://gateway;
    }
  ....
  }
# router
{
  "uri": "/*",
  "upstream_id": "xxxx",
  "name": "test"
}

# upstream
{
  "type": "roundrobin",
  "nodes": [
    {
      "host": "127.0.0.1",
      "port":3001 ,
      "weight": 1
    }
  ]
}

apisix does not complete the request properly, why?

Environment

kayx23 commented 1 day ago

what error?

bestjane commented 1 day ago

what error?

@kayx23 nginx returns http code 200, and apisix returns http code 404

Whether to set the schema to tcp in upstream?

kayx23 commented 1 day ago

If your upstream speaks HTTP (without TLS) then leave untouched

kayx23 commented 1 day ago

What error does APSIX return along with 404? 404 is not found. Does the route you request exist?

bestjane commented 1 day ago

What error does APSIX return along with 404? 404 is not found. Does the route you request exist?

@kayx23 I used the same request with apisix and nginx to access the following results, where only the port number was modified and the parameters and routes were consistent

APISIX example:

➜ curl -v --location --request POST 'http://xxx:9080/xxx
< HTTP/1.1 404 Not Found
< Content-Length: 0
< Connection: keep-alive
< Date: Fri, 20 Sep 2024 09:39:11 GMT
< Keep-Alive: timeout=4
< Proxy-Connection: keep-alive
< Server: APISIX/3.10.0
<
* Connection #0 to host 127.0.0.1 left intact

Nginx example:

➜ curl -v --location --request POST 'http://xxx:8888/xxx
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Access-Control-Allow-Headers: *
Access-Control-Allow-Methods: *
Access-Control-Allow-Origin: *
Cache-Control: no-cache
Connection: keep-alive
Content-Type: application/json
Date: Fri, 20 Sep 2024 09:41:52 GMT
Keep-Alive: timeout=4
Proxy-Connection: keep-alive
Server: nginx/1.20.1
X-Envoy-Upstream-Service-Time: 814
kayx23 commented 1 day ago

Should the port where it says 31380 be 3001

bestjane commented 1 day ago

Should the port where it says 31380 be 3001

@kayx23 no, this is an example I wrote to do a little desensitization.I can confirm that the configuration is correct.