Skip to content

nginx returns 400 bad request when receiving CONNECT request  #136

@ximeng890726

Description

@ximeng890726

Hi,

After installing dynamic modules, nginx can start without error. however it does process any proxy connect request. (http works fine, https connect does not work and 400 BAD REQUEST returned)

I am running nginx plus on 1.17.6 (i make the module .so with OSS version and put it into plus module folder). Is it not compatible with latest nginx version? Is there a way I can troubleshoot? Thank you.

[root@localhost conf.d]# nginx -v
nginx version: nginx/1.17.6 (nginx-plus-r20)

[root@localhost conf.d]# cat ep.conf
server {
listen 8080;

 # dns resolver used by forward proxying
 resolver                       8.8.8.8;

 # forward proxy for CONNECT request
 proxy_connect ;
 proxy_connect_allow            443 563;
 proxy_connect_connect_timeout  10s;
 proxy_connect_read_timeout     10s;
 proxy_connect_send_timeout     10s;

 # forward proxy for non-CONNECT request
 location / {
     proxy_pass http://$host;
     proxy_set_header Host $host;
 }

}

[root@localhost conf.d]# tail /var/log/nginx/access.log
10.1.10.153 - - [31/Dec/2019:15:24:16 +0800] "CONNECT github:443 HTTP/1.1" 400 157 "-" "-" "-"
10.1.10.153 - - [31/Dec/2019:15:26:41 +0800] "CONNECT github:443 HTTP/1.1" 400 157 "-" "-" "-"
10.1.10.153 - - [31/Dec/2019:15:26:42 +0800] "CONNECT github:443 HTTP/1.1" 400 157 "-" "-" "-"
10.1.10.153 - - [31/Dec/2019:15:26:42 +0800] "CONNECT github:443 HTTP/1.1" 400 157 "-" "-" "-"
10.1.10.153 - - [31/Dec/2019:15:26:42 +0800] "CONNECT github:443 HTTP/1.1" 400 157 "-" "-" "-"
10.1.10.153 - - [31/Dec/2019:15:26:43 +0800] "CONNECT github:443 HTTP/1.1" 400 157 "-" "-" "-"
10.1.10.153 - - [31/Dec/2019:15:26:43 +0800] "CONNECT github:443 HTTP/1.1" 400 157 "-" "-" "-"
10.1.10.153 - - [31/Dec/2019:15:26:43 +0800] "CONNECT github:443 HTTP/1.1" 400 157 "-" "-" "-"
10.1.10.153 - - [31/Dec/2019:15:26:44 +0800] "CONNECT github:443 HTTP/1.1" 400 157 "-" "-" "-"
10.1.10.153 - - [31/Dec/2019:15:26:44 +0800] "CONNECT github:443 HTTP/1.1" 400 157 "-" "-" "-"

[root@localhost ~]# curl https://github -v --proxy 10.1.10.152:8080

  • About to connect() to proxy 10.1.10.152 port 8080 (#0)
  • Trying 10.1.10.152...
  • Connected to 10.1.10.152 (10.1.10.152) port 8080 (#0)
  • Establish HTTP proxy tunnel to github:443

CONNECT github:443 HTTP/1.1
Host: github:443
User-Agent: curl/7.29.0
Proxy-Connection: Keep-Alive

< HTTP/1.1 400 Bad Request
< Server: nginx/1.17.6
< Date: Tue, 31 Dec 2019 07:24:16 GMT
< Content-Type: text/html
< Content-Length: 157
< Connection: close
<

  • Received HTTP code 400 from proxy after CONNECT
  • Connection #0 to host 10.1.10.152 left intact
    curl: (56) Received HTTP code 400 from proxy after CONNECT

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions