socks-nginx-module icon indicating copy to clipboard operation
socks-nginx-module copied to clipboard

Bug: HTTP 400 Bad Request

Open SjRNMzU opened this issue 8 years ago • 3 comments

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.

SjRNMzU avatar Oct 26 '16 16:10 SjRNMzU

Config

location / {
    socks_pass socks5://127.0.0.1:/65432;
    socks_set_host $MY_HOSTNAME;
    socks_set_header HOST $MY_HOSTNAME;
    socks_redirect off;
}

SjRNMzU avatar Oct 26 '16 16:10 SjRNMzU

Thank you for your report! That's very strange. I'll check it out once I finish some refactoring.

dannote avatar Oct 31 '16 15:10 dannote

Please try setting socks_http_version to 1.1.

dannote avatar Nov 17 '16 12:11 dannote