With this script you can redirect only spesific HTTP and Websocket requests of your web browser to your local (or any other) web applications.
This script can be run only with user priviliges. Mitmproxy has standalone executables for all OSes.
Add $HOME/.mitmproxy/mitmproxy-ca-cert.cert file to web browser (only current browser profile is enough). This certificate file is creating after the first run of mitmproxy.
For Firefox:
- Settings
- View Certificates
- Authorities
- Import
- Choose $HOME/.mitmproxy/mitmproxy-ca-cert.cert file only.
OS based certificate formats exist. Read this: https://docs.mitmproxy.org/stable/concepts-certificates/#the-mitmproxy-certificate-authority
Add proxy for http and https: localhost:44700
Linux
./mitmweb -s mitm-redirect-url.py --listen-port 44700
MS Windows
mitmweb.exe -s mitm-redirect-url.py --listen-port 44700
Optionally you can ignore CORS for your current browser profile. You can use below extension for Firefox:
https://addons.mozilla.org/en-US/firefox/addon/cors-everywhere/