Accessing Nginx specifies the reason for some Host request headers to request 499

access a third-party interface (such as ip3:8080/foo) via Nginx redirect

location /foo {
    proxy_pass http://ip3:8080/foo/;
}

Local = = > Nginx on Ali CVM (ip2) = > third-party interface
(third-party interface has a whitelist to restrict ip2 in whitelist)

found such a strange problem

when you specify some special Host request headers when accessing locally through Nginx, the access is unsuccessful as follows

  ~ curl "http://ip2/foo" -H "Host: bar.com"

<html>
<head>
<meta http-equiv="Content-Type" content="textml;charset=UTF-8" />
   <style>body{background-color:-sharpFFFFFF}</style>
<title>TestPage184</title>
  <script language="javascript" type="text/javascript">
         window.onload = function () {
           document.getElementById("mainFrame").src= "http://batit.aliyun.com/alww.html";
            }
</script>
</head>
  <body>
    <iframe style="width:860px; height:500px;position:absolute;margin-left:-430px;margin-top:-250px;top:50%;left:50%;" id="mainFrame" src="" frameborder="0" scrolling="no"></iframe>
    </body>
      </html>

the corresponding Nginx log is

222.128.172.216 - - [01/Nov/2018:12:37:39 +0800] "GET /foo HTTP/1.1" 499 0 "-" "curl/7.43.0" "-"

the return status code is 499

but there is no problem with directly accessing the same Host request header on the same third-party interface on the server where Nginx resides (ip2)

curl "http://ip3:8080/foo" -H "Host: bar.com"

and without specifying Host or any other Host when accessing locally through Nginx, there is no problem, such as

curl "http://ip2/foo"
curl "http://ip2/foo" -H "Host: 111.com"
curl "http://ip2/foo" -H "Host: 222.com"

Why is there a problem with some Host request headers (such as foo.com bar.com aaa.com) when accessing through Nginx, but it is not a problem for the same Host request header to access the third-party interface directly?

current solution

when Nginx is changed to listen on port 81, the problem is solved

curl "http://ip2:81/foo" -H "Host: bar.com"

how do you explain this?

Oct.09,2021

nginx
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36b6d-2c041.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36b6d-2c041.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?