Modules: skip the proxy CONNECT tunnel when no proxy is selected
ngx_js_http_connect() and the write handler chose between a forward
proxy CONNECT tunnel and a direct TLS handshake from
ngx_js_conf_proxy(), which only reports that js_fetch_proxy is
configured for the location.
When the proxy URL comes from a variable it is evaluated per request
and an empty value selects a direct connection. An "https" fetch in
such a location then connected to the origin while still being
treated as proxied: the cleartext CONNECT request was written to the
origin and the TLS handshake was never started.
Use ngx_js_http_proxy(), the per-request state the rest of the fetch
code already uses, in the connect and write paths. A static
js_fetch_proxy is unaffected because both predicates agree there.