I'd like to set up a map_remote rewrite from an https address to my local machine running a service on http only.
The documentation for the option (https://docs.mitmproxy.org/stable/concepts-options/) seems to indicate I should do this
mitmproxy --map-remote "|https://foo.bar.com|http://localhost:8081|"
But this doesn't seem to rewrite any requests.
What's the correct syntax to accomplish this?
The problem in your example is the trailing |
. Map Remote specifications can either be:
|flow-filter|url-regex|replacement
or|url-regex|replacement
By append a final |
to your two-part spec, you inadvertedly use the first form, and https://foo.bar.com
is applied as the filter and not as the url regex. Long story short:
mitmproxy --map-remote "|https://foo.bar.com|http://localhost:8081|" # wrong
mitmproxy --map-remote "|https://foo.bar.com|http://localhost:8081" # correct
You may also find the extended feature documentation at https://docs.mitmproxy.org/stable/overview-features/#map-remote helpful. :)