# Is https://localhost:8080 expected to work?

**URL:** <https://discourse.mitmproxy.org/t/is-https-localhost-8080-expected-to-work/1087>\
**Category:** help\
**Created:** [June 5, 2018, 7:40am UTC](https://discourse.mitmproxy.org/t/is-https-localhost-8080-expected-to-work/1087 "2018-06-05T07:40:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rageshkrishna](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/rageshkrishna/32/316_2.png) [@rageshkrishna](https://discourse.mitmproxy.org/u/rageshkrishna)\
**Post date:** [June 5, 2018, 7:40am UTC](https://discourse.mitmproxy.org/t/is-https-localhost-8080-expected-to-work/1087/1 "2018-06-05T07:40:30Z")

</div>

So the basic question is if `http_proxy=http://localhost:8080; https_proxy=https://localhost:8080` is supposed to work (specifically for the `https` part)?

Here is how I can reproduce the problem:

1. Start mitmproxy (`./mitmproxy``)
2. Run this node.js code:

```javascript
var request = require('request');
request.debug = true;

process.env.NODE_TLS_REJECT_UNAUTHORIZED=0;
process.env.https_proxy='http://localhost:8080';
process.env.no_proxy="localhost"

request({
  method: 'GET',
  uri: 'https://github.com',
  //proxy: 'http://localhost:8080', // Works
  proxy: 'https://localhost:8080' // Fails
});

```

3. The request hangs indefinitely

##### Any other comments? What have you tried so far?

Here is the event log with debug level turned on:

Using [http://localhost:8080](http://localhost:8080):

```auto
info: 127.0.0.1:59518: clientconnect
debug: ::ffff:127.0.0.1:59518: Set new server address: github.com:443
debug: ::ffff:127.0.0.1:59518: Establish TLS with client
debug: ::ffff:127.0.0.1:59518: request
  -> Request(GET /)
debug: ::ffff:127.0.0.1:59518: serverconnect
  -> ('github.com', 443)
debug: ::ffff:127.0.0.1:59518: Establish TLS with server
debug: ::ffff:127.0.0.1:59518: ALPN selected by server: -
debug: ::ffff:127.0.0.1:59518: response
  -> Response(200 OK, text/html; charset=utf-8, 56.75k)
debug: ::ffff:127.0.0.1:59518: serverdisconnect
  -> ('github.com', 443)
info: 127.0.0.1:59518: clientdisconnect

```

Using [https://localhost:8080](https://localhost:8080)

```auto
info: 127.0.0.1:59587: clientconnect
debug: ::ffff:127.0.0.1:59587: Establish TLS with client
debug: ::ffff:127.0.0.1:59587: Set new server address: github.com:443
debug: ::ffff:127.0.0.1:59587: Establish TLS with client

```

At this point, it just hangs indefinitely.

I’m not sure if this is really a valid scenario for mitmproxy. My only motivation to try this out was because I’ve seen environments where `http_proxy` points to `http://proxy:3128` and `https_proxy` points to `https://proxy:3128` and was testing the same setup with mitmproxy.

---

<div class="post-metadata">

**Author:** ![mhils](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/mhils/32/7_2.png) [@mhils](https://discourse.mitmproxy.org/u/mhils)\
**Post date:** [June 5, 2018, 2:03pm UTC](https://discourse.mitmproxy.org/t/is-https-localhost-8080-expected-to-work/1087/2 "2018-06-05T14:03:20Z")

</div>

Hi, we currently don’t support TLS over TLS, which would be required for what Chromium is calling [“Secure Web Proxy”](https://www.chromium.org/developers/design-documents/secure-web-proxy). We do have [plans to fix this](https://github.com/mitmproxy/mitmproxy/issues/1775#issue-191013270), but for your specific use case (proxy running on localhost) it should not matter.

Cheers,  
Max

---

<div class="post-metadata">

**Author:** ![rageshkrishna](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/rageshkrishna/32/316_2.png) [@rageshkrishna](https://discourse.mitmproxy.org/u/rageshkrishna)\
**Post date:** [June 6, 2018, 8:25am UTC](https://discourse.mitmproxy.org/t/is-https-localhost-8080-expected-to-work/1087/3 "2018-06-06T08:25:14Z")

</div>

Thank you, @mhils, for the answer. I wasn’t sure if it was mitmproxy or the request npm module that was the problem. This clears it up.
