# Upstream Proxy HTTPS

**URL:** <https://discourse.mitmproxy.org/t/upstream-proxy-https/452>\
**Category:** help\
**Created:** [April 20, 2017, 6:38am UTC](https://discourse.mitmproxy.org/t/upstream-proxy-https/452 "2017-04-20T06:38:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jake232](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/jake232/32/152_2.png) [@Jake232](https://discourse.mitmproxy.org/u/Jake232)\
**Post date:** [April 20, 2017, 6:38am UTC](https://discourse.mitmproxy.org/t/upstream-proxy-https/452/1 "2017-04-20T06:38:39Z")

</div>

I have my script changing the upstream proxy for HTTP connections, but it seems to fail for HTTPS connections. Here’s a basic stripped down example.

The script works fine for [http://api.ipify.org/](http://api.ipify.org/), but fails for [https://api.ipify.org/](https://api.ipify.org/). With HTTPS I see the following, which shows the upstream proxy wasn’t changed.

```
Server connection to default_proxy:8888 failed: Error connecting to "default_proxy": [Errno 8] nodename nor servname provided, or not known

```

> <https://gist.github.com/JakeAustwick/c3116d86f4483d1acede4420f02efb72>

Running Command:  
`mitmdump -s utilities/proxy_redirects.py -U http://default_proxy:8888`

---

<div class="post-metadata">

**Author:** ![Jake232](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/jake232/32/152_2.png) [@Jake232](https://discourse.mitmproxy.org/u/Jake232)\
**Post date:** [April 20, 2017, 6:39am UTC](https://discourse.mitmproxy.org/t/upstream-proxy-https/452/2 "2017-04-20T06:39:23Z")

</div>

Platform / Library Version:

mitmdump --version  
Mitmproxy version: 2.0.1 (release version)  
Python version: 3.6.1  
Platform: Darwin-14.5.0-x86\_64-i386-64bit  
SSL version: OpenSSL 1.1.0e 16 Feb 2017  
Mac version: 10.10.5 (’’, ‘’, ‘’) x86\_64

---

<div class="post-metadata">

**Author:** ![Jake232](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/jake232/32/152_2.png) [@Jake232](https://discourse.mitmproxy.org/u/Jake232)\
**Post date:** [April 20, 2017, 6:42am UTC](https://discourse.mitmproxy.org/t/upstream-proxy-https/452/3 "2017-04-20T06:42:30Z")

</div>

It looks like somebody maybe had a similar error here, and upgrading fixed it. But I’m already on 2.x.

> [@Change upstream proxy for https flow](https://discourse.mitmproxy.org/t/change-upstream-proxy-for-https-flow/347):
>
> My eventual goal is to dynamically change the upstream proxy of my https flow based on the domain of the destination server or the value of a header. For now, I’m just trying to get a minimal example working following the example of [https://github.com/mitmproxy/mitmproxy/blob/master/examples/complex/change\_upstream\_proxy.py](https://github.com/mitmproxy/mitmproxy/blob/master/examples/complex/change_upstream_proxy.py) but I’m not getting the expected results. I run mitmdump in upstream mode like so: mitmdump -U https://default-proxy:port -s change-upstream.py With this script def requ…

---

<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:** [April 21, 2017, 2:41pm UTC](https://discourse.mitmproxy.org/t/upstream-proxy-https/452/4 "2017-04-21T14:41:20Z")

</div>

See [https://github.com/mitmproxy/mitmproxy/issues/2253](https://github.com/mitmproxy/mitmproxy/issues/2253)

---

<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:** [April 21, 2017, 2:41pm UTC](https://discourse.mitmproxy.org/t/upstream-proxy-https/452/5 "2017-04-21T14:41:24Z")

</div>


