# Redirects through reverse proxy

**URL:** <https://discourse.mitmproxy.org/t/redirects-through-reverse-proxy/1250>\
**Category:** help\
**Created:** [September 20, 2018, 9:33pm UTC](https://discourse.mitmproxy.org/t/redirects-through-reverse-proxy/1250 "2018-09-20T21:33:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davclark](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/davclark/32/348_2.png) [@davclark](https://discourse.mitmproxy.org/u/davclark)\
**Post date:** [September 20, 2018, 9:33pm UTC](https://discourse.mitmproxy.org/t/redirects-through-reverse-proxy/1250/1 "2018-09-20T21:33:23Z")

</div>

I’m trying to build out some notifications when certain RStudio events happen using an mitmproxy add-on. RStudio itself only needs regular HTTP, but these directions also include making websockets work, as that is required by Shiny: [https://support.rstudio.com/hc/en-us/articles/200552326-Running-RStudio-Server-with-a-Proxy](https://support.rstudio.com/hc/en-us/articles/200552326-Running-RStudio-Server-with-a-Proxy)

By default RStudio runs on port 8787, so I’m trying to reverse proxy as follows:

`mitmdump -p 8888 --mode reverse:http://localhost:8787/`

Right away, there’s a redirect and the port number is lost - so the redirect is to `localhost/auth-sign-in` (the port number is not properly re-written).

Based on my understanding of mitmproxy and the instructions I linked above, mitmproxy should by default properly rewrite redirect links, or am I missing something?

---

<div class="post-metadata">

**Author:** ![davclark](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/davclark/32/348_2.png) [@davclark](https://discourse.mitmproxy.org/u/davclark)\
**Post date:** [October 9, 2018, 4:07pm UTC](https://discourse.mitmproxy.org/t/redirects-through-reverse-proxy/1250/2 "2018-10-09T16:07:11Z")

</div>

So, we can get to the point that we re-write ports by adding `--setheader :~q:Host:localhost:8080`. There is still no way we can find to re-write prefixes on the URL path.
