Blocking Ads on Reddit’s iOS App: A Step-by-Step Guide
Using mitmproxy to Create a Self-Hosted Ad Blocker
I recently stumbled upon a clever way to block ads on Reddit’s iOS app using a self-hosted mitmproxy. As someone who values a clean and ad-free browsing experience, I was excited to dive in and try it out. In this post, I’ll walk you through the process of setting up mitmproxy and blocking ads on Reddit’s iOS app.
The method involves using a small Python script to filter out ads from the Reddit API. I’ll provide a step-by-step guide on how to install mitmproxy, configure it, and enable it on your iPhone. I’ll also share some tips and tricks I learned along the way, including how to use Tailscale to block ads on your phone even when you’re out of the house.
Getting Started with mitmproxy
The first step is to install mitmproxy. You can find the official documentation on the mitmproxy website, which provides detailed instructions for various operating systems. I recommend using the mitmproxy/mitmproxy
Docker container, which makes it easy to get started. Once you have mitmproxy installed, you’ll need to configure it to work with the Reddit API.
To do this, you’ll need to download a small Python script that filters out ads from the Reddit API. You can find the script on GitHub, and it’s easy to download and install. Once you have the script, you can run mitmproxy with the following options:
-s /path/to/addon.py --listen-host 0.0.0.0 --listen-port 8080 --allow-hosts '^gql-fed\.reddit\.com(?::\d+)?$'
This will start mitmproxy and configure it to listen on port 8080. You can adjust the port number to your liking, but make sure to update the configuration accordingly.
Enabling mitmproxy on Your iPhone
Once you have mitmproxy up and running, you’ll need to enable it on your iPhone. To do this, go to the Settings app and select the Wi-Fi network you’re connected to. Tap on the “i” icon next to the network name, and then select “HTTP Proxy” from the menu. Enter the IP address or hostname of your mitmproxy server, and select “Manual” as the proxy type.
Next, you’ll need to install the mitmproxy CA on your iPhone. To do this, go to the mitm.it
magic domain and follow the instructions to install the CA. This will allow your iPhone to trust the mitmproxy server and establish a secure connection.
Tailscale Tip: Blocking Ads on the Go
One of the coolest things about using mitmproxy is that you can block ads on your phone even when you’re out of the house. To do this, you’ll need to set up Tailscale, which allows you to create a secure and private network between your devices. Once you have Tailscale up and running, you can use the Tailscale machine name as the proxy server on your iPhone.
For example, if you have mitmproxy running on a laptop, you can use the laptop’s machine name as the proxy server. If you have mitmproxy running in a Docker container on a machine, you can install Tailscale on that machine and expose a port in Docker. Then, you can use the Tailscale hostname of the underlying machine as the proxy server.
Extending the Addon
The addon I used to block ads on Reddit’s iOS app is a small Python script that filters out ads from the Reddit API. However, you can extend the addon to block ads on other apps and services as well. To do this, you can use the mitmweb program, which is a Chrome DevTools-like web app that lists the requests and responses for you to examine.
You can then tweak the addon code and re-test it to see how it works. This is a great way to learn more about how mitmproxy works and how you can use it to block ads on other apps and services.
In conclusion, blocking ads on Reddit’s iOS app using mitmproxy is a great way to create a clean and ad-free browsing experience. With this step-by-step guide, you should be able to get started and block ads on your iPhone in no time. Happy browsing!
Blockowanie Reklam w Aplikacji Reddit na iOS: Przewodnik Krok po Kroku
Użycie mitmproxy do Stworzenia Samo-Hostowanego Blokera Reklam
Niedawno odkryłem inteligentny sposób, aby zablokować reklamy w aplikacji Reddit na iOS przy użyciu samo-hostowanego mitmproxy. Jako osoba, która ceni czyste i wolne od reklam doświadczenie przeglądania, byłem podekscytowany, aby spróbować. W tym poście, oprowadzę Cię przez proces instalacji mitmproxy, konfiguracji go i włączenia na Twoim iPhone.
Metoda ta polega na użyciu małego skryptu Python, aby wyfiltrować reklamy z API Reddit. Będę udostępniać przewodnik krok po kroku, jak zainstalować mitmproxy, skonfigurować go i włączyć na Twoim iPhone. Będę także udostępniać wskazówki i sztuczki, które nauczyłem się po drodze, w tym jak użyć Tailscale, aby zablokować reklamy na Twoim telefonie, nawet gdy jesteś poza domem.
Rozpoczęcie Pracy z mitmproxy
Pierwszym krokiem jest zainstalowanie mitmproxy. Możesz znaleźć oficjalną dokumentację na stronie mitmproxy, która zapewnia szczegółowe instrukcje dla różnych systemów operacyjnych. Zalecam używanie kontenera Docker mitmproxy/mitmproxy
, który ułatwia rozpoczęcie pracy. Gdy tylko zainstalujesz mitmproxy, będziesz musiał go skonfigurować, aby działał z API Reddit.
Aby to zrobić, będziesz musiał pobrać mały skrypt Python, który wyfiltrowuje reklamy z API Reddit. Możesz znaleźć skrypt na GitHub, i jest on łatwy do pobrania i zainstalowania. Gdy tylko pobierzesz skrypt, możesz uruchomić mitmproxy z następującymi opcjami:
-s /path/to/addon.py --listen-host 0.0.0.0 --listen-port 8080 --allow-hosts '^gql-fed\.reddit\.com(?::\d+)?$'
To spowoduje uruchomienie mitmproxy i skonfigurowanie go do nasłuchiwania na porcie 8080. Możesz dostosować numer portu do swoich potrzeb, ale pamiętaj, aby zaktualizować konfigurację odpowiednio.
Włączenie mitmproxy na Twoim iPhone
Gdy tylko zainstalujesz i skonfigurujesz mitmproxy, będziesz musiał go włączyć na swoim iPhone. Aby to zrobić, przejdź do aplikacji Ustawienia i wybierz sieć Wi-Fi, z którą jesteś połączony. Naciśnij ikonę “i” obok nazwy sieci, a następnie wybierz “HTTP Proxy” z menu. Wprowadź adres IP lub nazwę hosta serwera mitmproxy i wybierz “Ręczny” jako typ serwera proxy.
Następnie będziesz musiał zainstalować certyfikat mitmproxy na swoim iPhone. Aby to zrobić, przejdź do domeny mitm.it
i postępuj zgodnie z instrukcjami, aby zainstalować certyfikat. To pozwoli Twojemu iPhone’owi zaufać serwerowi mitmproxy i nawiązać bezpieczne połączenie.
Wskazówka Tailscale: Blokowanie Reklam w Ruchu
Jedną z najfajniejszych rzeczy w użyciu mitmproxy jest to, że możesz zablokować reklamy na swoim telefonie, nawet gdy jesteś poza domem. Aby to zrobić, będziesz musiał skonfigurować Tailscale, który pozwala stworzyć bezpieczną i prywatną sieć między Twoimi urządzeniami. Gdy tylko skonfigurujesz Tailscale, możesz użyć nazwy hosta Tailscale jako serwera proxy na swoim iPhone.
Na przykład, jeśli masz mitmproxy uruchomiony na laptopie, możesz użyć nazwy hosta laptopa jako serwera proxy. Jeśli masz mitmproxy uruchomiony w kontenerze Docker na maszynie, możesz zainstalować Tailscale na tej maszynie i udostępnić port w Docker. Następnie możesz użyć nazwy hosta Tailscale maszyny podstawowej jako serwera proxy.
Rozszerzanie Wtyczki
Wtyczka, którą użyłem do zablokowania reklam w aplikacji Reddit na iOS, jest małym skryptem Python, który wyfiltrowuje reklamy z API Reddit. Możesz jednak rozszerzyć wtyczkę, aby zablokować reklamy w innych aplikacjach i usługach. Aby to zrobić, możesz użyć programu mitmweb, który jest aplikacją webową podobną do Chrome DevTools, która wyświetla żądania i odpowiedzi do zbadania.
Możesz następnie dostosować kod wtyczki i przetestować go, aby zobaczyć, jak działa. To jest świetny sposób, aby nauczyć się więcej o tym, jak działa mitmproxy i jak możesz go użyć, aby zablokować reklamy w innych aplikacjach i usługach.
Podsumowując, blokowanie reklam w aplikacji Reddit na iOS przy użyciu mitmproxy jest świetnym sposobem, aby stworzyć czyste i wolne od reklam doświadczenie przeglądania. Z tym przewodnikiem krok po kroku, powinieneś być w stanie zacząć i zablokować reklamy na swoim iPhone w krótkim czasie. Szczęśliwego przeglądania!