socks-nginx-module
socks-nginx-module copied to clipboard
Bug: HTTP 400 Bad Request
Hi, I'm using the socks plugin to route a request via a socks proxy. I have tried a simple loopback i.e. request example.com -> (socks proxy) -> example.com
Request example.com resolves to machine A and connects to nginx SOCKS5 proxy listening at localhost:xxx on machine A, connected to machine B. Request is routed via the SOCKS5 proxy but when trying to do the HTTP request I get HTTP 400 error.
Here's the access log:
"GET\x00/IJKT_QHYF/index.php/DGH_Wiki/ HTTP/1.1" 400 173 "-" "-"
as apposed to a normal request directly to example.com (machine A):
"GET /IJKT_QHYF/index.php/DGH_Wiki/ HTTP/1.1" 401 597 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)"
As you can see the HTTP headers are garbled with \x00 encoded between GET and the location.
Config
location / {
socks_pass socks5://127.0.0.1:/65432;
socks_set_host $MY_HOSTNAME;
socks_set_header HOST $MY_HOSTNAME;
socks_redirect off;
}
Thank you for your report! That's very strange. I'll check it out once I finish some refactoring.
Please try setting socks_http_version
to 1.1.