schubidos commented on issue #8747:
URL: https://github.com/apache/apisix/issues/8747#issuecomment-1409940691

   The problem with `"pass_host": "pass"` is, that the request is routed then 
to example.com instead of httpbin.org.
   
   I tried this:
   ## Set `"pass_host": "pass"`
   Call `curl -i -X GET 
"http://127.0.0.1:9080/anything/get?foo1=bar1&foo2=bar2"; -H "Host: example.com"`
   Result (comes from **example.com!!!**):
   ```
   HTTP/1.1 404 Not Found
   Content-Type: text/html; charset=UTF-8
   Content-Length: 1256
   Connection: keep-alive
   Accept-Ranges: bytes
   Age: 178498
   Cache-Control: max-age=604800
   Date: Tue, 31 Jan 2023 08:03:09 GMT
   Expires: Tue, 07 Feb 2023 08:03:09 GMT
   Last-Modified: Sun, 29 Jan 2023 06:28:11 GMT
   Vary: Accept-Encoding
   X-Cache: 404-HIT
   Server: APISIX/3.1.0
   
   <!doctype html>
   <html>
   <head>
       <title>Example Domain</title>
   
       <meta charset="utf-8" />
       <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
       <meta name="viewport" content="width=device-width, initial-scale=1" />
       <style type="text/css">
       body {
           background-color: #f0f0f2;
           margin: 0;
           padding: 0;
           font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe 
UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
   
       }
       div {
           width: 600px;
           margin: 5em auto;
           padding: 2em;
           background-color: #fdfdff;
           border-radius: 0.5em;
           box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);
       }
       a:link, a:visited {
           color: #38488f;
           text-decoration: none;
       }
       @media (max-width: 700px) {
           div {
               margin: 0 auto;
               width: auto;
           }
       }
       </style>
   </head>
   
   <body>
   <div>
       <h1>Example Domain</h1>
       <p>This domain is for use in illustrative examples in documents. You may 
use this
       domain in literature without prior coordination or asking for 
permission.</p>
       <p><a href="https://www.iana.org/domains/example";>More 
information...</a></p>
   </div>
   </body>
   </html>
   ```
   
   ## Set `"pass_host": "node"`
   Call `curl -i -X GET 
"http://127.0.0.1:9080/anything/get?foo1=bar1&foo2=bar2"; -H "Host: example.com"`
   Result as expected (From doc: `APISIX will forward the request to 
http://httpbin.org:80/anything/foo?arg=10`.):
   ```
   HTTP/1.1 200 OK
   Content-Type: application/json
   Content-Length: 462
   Connection: keep-alive
   Date: Tue, 31 Jan 2023 08:12:01 GMT
   Access-Control-Allow-Origin: *
   Access-Control-Allow-Credentials: true
   Server: APISIX/3.1.0
   
   {
     "args": {
       "foo1": "bar1",
       "foo2": "bar2"
     },
     "data": "",
     "files": {},
     "form": {},
     "headers": {
       "Accept": "*/*",
       "Host": "httpbin.org",
       "User-Agent": "curl/7.68.0",
       "X-Amzn-Trace-Id": "Root=1-63d8cd51-704a662e2fe620074111b518",
       "X-Forwarded-Host": "example.com"
     },
     "json": null,
     "method": "GET",
     "origin": "172.18.0.1, 213.225.34.217",
     "url": "http://example.com/anything/get?foo1=bar1&foo2=bar2";
   }
   ```
   
   
   I'm just exploring APISIX, so I can't say if it is an error in the docs (as 
I thought), or a bug. The only thing I see is, that the described steps don't 
deliver the described result.


-- 
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.

To unsubscribe, e-mail: [email protected]

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

Reply via email to