Nginx as forward proxy for HTTPS

httpsnginxPROXY

While I was able to successfully configure nginx to proxy HTTP traffic (using this guide), all attempts to proxy HTTPS requests resulted in code 400 (Bad Request).

Nginx debug logs weren't helpful at all:

2013/06/05 14:38:33 [info] 74946#0: *589
    client sent invalid request while reading client request line, client: 127.0.0.1,
    server: google.com, request: "CONNECT google.com:443 HTTP/1.1"

What are these CONNECT requests? Is it even possible to proxy_pass HTTPS requests in nginx?

Update

Need to add that a proxy server is part of my web development workflow/toolkit. It's a great way to test/debug client-side JavaScript in production environment (using rewrites before the proxy).

Also nginx's config language is arguably a programming language in it's own right. It has variables!

Best Answer

Seems like nginx does not support forward proxy mode with SSL. You will need to use something like Squid instead. Here is a link with more explanation from nginx's author: HTTPS and nginx as Forward Proxy.

Related Question