chobits / ngx_http_proxy_connect_module

A forward proxy module for CONNECT request handling
BSD 2-Clause "Simplified" License
1.84k stars 498 forks source link

response 404 #283

Closed hackeryutu closed 1 year ago

hackeryutu commented 1 year ago

Why can I get a normal response when accessing the address without a proxy server, but when accessing it through a proxy, I receive a 404 response code?

~ ❯ curl test.51kys.cn:7681/api/general/package/list -sv -x 192.168.1.88:3128
*   Trying 192.168.1.88:3128...
* Connected to 192.168.1.88 (192.168.1.88) port 3128 (#0)
> GET http://test.51kys.cn:7681/api/general/package/list HTTP/1.1
> Host: test.51kys.cn:7681
> User-Agent: curl/7.88.1
> Accept: */*
> Proxy-Connection: Keep-Alive
>
< HTTP/1.1 404 Not Found
< Server: nginx/1.24.0
< Date: Mon, 07 Aug 2023 05:37:01 GMT
< Content-Type: text/html
< Content-Length: 153
< Connection: keep-alive
<
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.19.9</center>
</body>
</html>
* Connection #0 to host 192.168.1.88 left intact
~ ❯ curl test.51kys.cn:7681/api/general/package/list -sv
*   Trying 183.238.185.202:7681...
* Connected to test.51kys.cn (183.238.185.202) port 7681 (#0)
> GET /api/general/package/list HTTP/1.1
> Host: test.51kys.cn:7681
> User-Agent: curl/7.88.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Cache-Control: no-cache
< Pragma: no-cache
< Content-Length: 53
< Content-Type: application/json; charset=utf-8
< Expires: -1
< Server: Microsoft-IIS/7.5
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: Content-Type
< Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
< X-AspNet-Version: 0
< X-Powered-By: WAF/2.0
< Date: Mon, 07 Aug 2023 05:27:52 GMT
<
* Connection #0 to host test.51kys.cn left intact
{"code":1,"message":"请求头参数timestamp为空"}%

nginx access log

"GET http://test.51kys.cn:7681/api/general/package/list HTTP/1.1" 404 153 "-" "curl/7.88.1"

nginx conf

image

hackeryutu commented 1 year ago

It may be that the port number was lost during the forwarding process

hackeryutu commented 1 year ago

problem fix

$host -> $http_host

chobits commented 1 year ago

Thats impressive that you are able to fix it on your own!