Firstsawyou commented on issue #3284:
URL: https://github.com/apache/apisix/issues/3284#issuecomment-760113766


   Hi, @dickens7 
   I did not reproduce your problem in APISIX v2.2.
   Here are the steps I reproduced:
   1、APISIX version
   ```shell
    ./bin/apisix version
   2.2
   ```
   
   2、add global_rules
   
   ```shell
   $ curl -X PUT \
   >   http://127.0.0.1:9080/apisix/admin/global_rules/1 \
   >   -H 'Content-Type: application/json' \
   >   -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
   >   -d '{"plugins": {"cors": {}}}'
   
   
{"node":{"value":{"plugins":{"cors":{"allow_credential":false,"allow_origins":"*","allow_headers":"*","expose_headers":"*","max_age":5,"allow_methods":"*"}},"id":"1"},"key":"\/apisix\/global_rules\/1"},"action":"set"}
   ```
   
   3、add route
   
   ```shell
   $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: 
edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
   {
       "uri": "/*",
       "upstream": {
           "type": "roundrobin",
           "nodes": {
               "127.0.0.1:80": 1
           }
       }
   }'
   HTTP/1.1 200 OK
   Server: openresty
   Date: Thu, 14 Jan 2021 10:35:17 GMT
   Content-Type: application/json
   Transfer-Encoding: chunked
   Connection: keep-alive
   Access-Control-Allow-Origin: *
   Access-Control-Allow-Credentials: true
   Access-Control-Expose-Headers: *
   Access-Control-Max-Age: 3600
   
   
{"node":{"value":{"upstream":{"type":"roundrobin","pass_host":"pass","hash_on":"vars","nodes":{"127.0.0.1:80":1}},"status":1,"create_time":1610288363,"update_time":1610620517,"uri":"\/*","priority":0,"id":"1"},"key":"\/apisix\/routes\/1"},"action":"set"}
   ```
   
   4、Initiate a request (upstream service is available):
   
   ```shell
   $ curl http://127.0.0.1:9080/hello -i
   HTTP/1.1 200 OK
   Content-Type: application/octet-stream
   Transfer-Encoding: chunked
   Connection: keep-alive
   Date: Thu, 14 Jan 2021 10:36:24 GMT
   Server: APISIX/2.2
   Access-Control-Allow-Origin: *
   Access-Control-Allow-Methods: *
   Access-Control-Max-Age: 5
   Access-Control-Expose-Headers: *
   Access-Control-Allow-Headers: *
   
   80 service.
   ```
   
   5、Initiate a request (upstream is not available):
   
   ```shell
   curl http://127.0.0.1:9080/hello -i
   HTTP/1.1 502 Bad Gateway
   Date: Thu, 14 Jan 2021 10:39:49 GMT
   Content-Type: text/html; charset=utf-8
   Content-Length: 154
   Connection: keep-alive
   Server: APISIX/2.2
   X-APISIX-Upstream-Status: 502
   Access-Control-Allow-Origin: *
   Access-Control-Allow-Methods: *
   Access-Control-Max-Age: 5
   Access-Control-Expose-Headers: *
   Access-Control-Allow-Headers: *
   
   <html>
   <head><title>502 Bad Gateway</title></head>
   <body>
   <center><h1>502 Bad Gateway</h1></center>
   <hr><center>openresty</center>
   </body>
   </html>
   ```
   
    error log:
   
   ```
   2021/01/14 18:41:53 [error] 27477#27477: *2707934 connect() failed (111: 
Connection refused) while connecting to upstream, client: 127.0.0.1, server: , 
request: "GET /hello HTTP/1.1", upstream: "http://127.0.0.1:80/hello";, host: 
"127.0.0.1:9080"
   2021/01/14 18:41:55 [error] 27476#27476: *2708040 connect() failed (111: 
Connection refused) while connecting to upstream, client: 127.0.0.1, server: , 
request: "GET /hello HTTP/1.1", upstream: "http://127.0.0.1:80/hello";, host: 
"127.0.0.1:9080"
   2021/01/14 18:41:56 [error] 27476#27476: *2708075 connect() failed (111: 
Connection refused) while connecting to upstream, client: 127.0.0.1, server: , 
request: "GET /hello HTTP/1.1", upstream: "http://127.0.0.1:80/hello";, host: 
"127.0.0.1:9080"
   ```
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to