Uncategorized

How to block ads in Reddit iOS app via self-hosted mitmproxy

How to Block Ads in the Reddit iOS App: A Step-by-Step Guide

Using mitmproxy to Create a Self-Hosted Ad Blocker

As a Reddit user, I was getting tired of the constant ads popping up in my feed. I wanted to find a way to block them without having to pay for a premium subscription. After some research, I stumbled upon a solution that uses mitmproxy, an HTTPS proxy that can decrypt and modify traffic. In this post, I’ll walk you through the process of setting up a self-hosted mitmproxy to block ads in the Reddit iOS app.

The first step is to install mitmproxy. You can find the official installation instructions on the mitmproxy website. I used the mitmproxy Docker container, which made the process relatively straightforward. Once you have mitmproxy installed, you’ll need to configure it to work with the Reddit app.

Configuring mitmproxy

To configure mitmproxy, you’ll need to download a small Python script that will act as an addon to filter out ads from the Reddit API. You can find the script on GitHub. Once you have the script, you’ll need to 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 tell mitmproxy to listen on port 8080 and allow traffic to the Reddit API. You’ll also need to enable mitmproxy on your iPhone by going to the HTTP Proxy options in the settings page for your wifi network. Simply enter the IP address or hostname of the machine running mitmproxy, and you’re good to go.

Installing the mitmproxy CA

Before you can start blocking ads, you’ll need to install the mitmproxy CA on your iPhone. To do this, go to the mitm.it website and follow the instructions. This will allow mitmproxy to decrypt and modify traffic from the Reddit app.

Once you’ve installed the CA, you should start seeing the ads disappear from your feed. It’s a pretty cool feeling, and it’s amazing how much of a difference it makes to the overall user experience.

Tips and Variations

If you want to take your ad blocking to the next level, you can use a service like Tailscale to create a virtual private network (VPN) that will allow you to block ads on your phone even when you’re not connected to your home network. Simply set up Tailscale on the machine running mitmproxy, and then use the Tailscale machine name as the proxy server on your iPhone.

Another option is to run mitmproxy in a Docker container on a machine, and then expose the port to the outside world. This will allow you to block ads on your phone from anywhere, as long as you have an internet connection.

Extending the Addon

If you’re feeling adventurous, you can try extending the addon to block ads on other apps or websites. The mitmweb program is a great tool for examining traffic and modifying the addon code. You can use it to tweak the addon and re-test it until you get the results you want.

Overall, setting up a self-hosted mitmproxy to block ads in the Reddit iOS app is a relatively straightforward process. With a little patience and persistence, you can create a custom ad blocker that will make your Reddit experience much more enjoyable.

Jak zablokować reklamy w aplikacji Reddit na iOS: Przewodnik krok po kroku

Używanie mitmproxy do utworzenia samodzielnie hostowanego blokera reklam

Jako użytkownik Reddit, miałem dość ciągłych reklam pojawiających się w moim feedzie. Chciałem znaleźć sposób, aby je zablokować bez konieczności płacenia za subskrypcję premium. Po pewnym czasie badań, natknąłem się na rozwiązanie, które wykorzystuje mitmproxy, serwer proxy HTTPS, który może odszyfrowywać i modyfikować ruch. W tym poście, opowiem o procesie konfigurowania samodzielnie hostowanego mitmproxy do zablokowania reklam w aplikacji Reddit na iOS.

Pierwszym krokiem jest zainstalowanie mitmproxy. Możesz znaleźć oficjalne instrukcje instalacji na stronie mitmproxy. Użyłem kontenera Docker mitmproxy, który uczynił proces dość prostym. Gdy masz zainstalowany mitmproxy, musisz go skonfigurować do pracy z aplikacją Reddit.

Konfigurowanie mitmproxy

Aby skonfigurować mitmproxy, musisz pobrać mały skrypt Python, który będzie działał jako wtyczka do filtrowania reklam z API Reddit. Możesz znaleźć skrypt na GitHub. Gdy masz skrypt, musisz 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 powie mitmproxy, aby nasłuchiwał na porcie 8080 i zezwolił na ruch do API Reddit. Musisz również włączyć mitmproxy na swoim iPhone, przechodząc do opcji proxy HTTP w ustawieniach sieci wifi. Wystarczy wprowadzić adres IP lub nazwę hosta maszyny, na której działa mitmproxy, i gotowe.

Instalowanie certyfikatu mitmproxy

Przed rozpoczęciem blokowania reklam, musisz zainstalować certyfikat mitmproxy na swoim iPhone. Aby to zrobić, przejdź do strony mitm.it i postępuj zgodnie z instrukcjami. To pozwoli mitmproxy odszyfrowywać i modyfikować ruch z aplikacji Reddit.

Gdy zainstalujesz certyfikat, powinieneś zacząć widzieć, jak reklamy znikają z twojego feedu. To dość fajne uczucie, i jest niesamowite, jak dużą różnicę to robi w ogólnym doświadczeniu użytkownika.

Porady i wariacje

Jeśli chcesz podnieść blokowanie reklam na wyższy poziom, możesz użyć usługi takiej jak Tailscale, aby utworzyć wirtualną sieć prywatną (VPN), która pozwoli ci blokuje reklamy na twoim telefonie nawet wtedy, gdy nie jesteś połączony z siecią domową. Wystarczy skonfigurować Tailscale na maszynie, na której działa mitmproxy, a następnie użyć nazwy hosta Tailscale jako serwera proxy na twoim iPhone.

Inna opcja to uruchomić mitmproxy w kontenerze Docker na maszynie, a następnie udostępnić port do świata zewnętrznego. To pozwoli ci blokuje reklamy na twoim telefonie z dowolnego miejsca, o ile masz połączenie z internetem.

Rozszerzanie wtyczki

Jeśli czujesz się awanturniczo, możesz spróbować rozszerzyć wtyczkę, aby zablokować reklamy w innych aplikacjach lub na stronach internetowych. Program mitmweb jest doskonałym narzędziem do badania ruchu i modyfikowania kodu wtyczki. Możesz go użyć, aby dostosować wtyczkę i ponownie przetestować ją, aż uzyskasz pożądane wyniki.

Podsumowując, konfigurowanie samodzielnie hostowanego mitmproxy do zablokowania reklam w aplikacji Reddit na iOS jest dość prostym procesem. Z trochą cierpliwości i wytrwałości, możesz utworzyć niestandardowego blokera reklam, który uczyni twoje doświadczenie Reddit znacznie przyjemniejszym.

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress Appliance - Powered by TurnKey Linux