# Mixing transparent mode and upstream mode

**URL:** <https://discourse.mitmproxy.org/t/mixing-transparent-mode-and-upstream-mode/721>\
**Category:** help\
**Created:** [November 21, 2017, 6:26pm UTC](https://discourse.mitmproxy.org/t/mixing-transparent-mode-and-upstream-mode/721 "2017-11-21T18:26:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![robotman3000](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/robotman3000/32/236_2.png) [@robotman3000](https://discourse.mitmproxy.org/u/robotman3000)\
**Post date:** [November 21, 2017, 6:26pm UTC](https://discourse.mitmproxy.org/t/mixing-transparent-mode-and-upstream-mode/721/1 "2017-11-21T18:26:19Z")

</div>

Hi, I am setting up an internet gateway that runs e2guardian with sslmitm mode enabled. What I want to do is setup the gateway machine to transparently redirect HTTP and HTTPS requests to the instance of e2guardian running on port `8080`. Mitmproxy would be the entity that does the redirection, hence the mixing transparent and upstream mode. I have been using iptables nat’ing rules to catch all port `80` and `443` traffic and redirect it to `127.0.0.1:1234` on the gateway machine where mitmproxy is listening, mitmproxy however can only forward **or** intercept but not both. Is what I am trying to do even possible using mitmproxy? Finally, not trying to sound harsh, but to anyone who thinks this can’t be done at all, please take a look at [proxy.py](https://github.com/robotman3000/proxil/blob/master/src/proxy.py). This is code I wrote (heavily modified really) as a proof of concept test. Thanks

---

<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:** [November 25, 2017, 11:08am UTC](https://discourse.mitmproxy.org/t/mixing-transparent-mode-and-upstream-mode/721/2 "2017-11-25T11:08:45Z")

</div>

If I understand you correctly, you are just looking for a tool that transparently wraps connections and tunnels them through an HTTP proxy. There are a few dedicated tools to do this, e.g. redsocks - how about using one of those?

---

<div class="post-metadata">

**Author:** ![robotman3000](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/robotman3000/32/236_2.png) [@robotman3000](https://discourse.mitmproxy.org/u/robotman3000)\
**Post date:** [November 26, 2017, 7:33pm UTC](https://discourse.mitmproxy.org/t/mixing-transparent-mode-and-upstream-mode/721/3 "2017-11-26T19:33:19Z")

</div>

You have understood me correctly, and actually I had already found redsocks but I couldn’t manage to get it working. It would always accept my connection but then never complete and eventually the connection would timeout. I found one or two other programs that seemed to be able to do HTTP CONNECT tunneling but I was not able to get them working either. Could you please give me a list of the tools you are aware of?
