Nitter in 2024

2024/09/05

Earlier this year, Nitter has ceased development, due to the removal of guest accounts, but, you can still self host an alternative Twitter frontend, and we’ll do it with something some love and some hate, Docker!

We will be using Privacydevel’s Nitter fork for this.

Prerequisites:

Step 1. Getting accounts

For this you will need a residential IP, as the login script won’t work otherwise. You can simply run it on your computer or on your phone using something like Termux.

After you get a bunch of alts, it is time to get their oauth tokens.

curl https://raw.githubusercontent.com/PrivacyDevel/nitter/master/twitter_oauth.sh -o twitter_oauth.sh
vim twitter_oauth.sh

twitter_oauth.sh

...
5 | username="yourUsernameHere"
6 | password="yourPasswordHere"
...
bash twitter_oauth.sh

You’ll end up with something similar in your terminal:

{"oauth_token":"SECRET", "oauth_token_secret":"SECRET"}

Save it for later.

Setting up Nitter

# Clone the instance. We will be using /srv/nitter
$ git clone https://github.com/PrivacyDevel/nitter.git /srv/nitter
# Now we have to edit the guest_accounts.json file
$ vim guest_accounts.json

guest_accounts.json

[{"oauth_token":"SECRET", "oauth_token_secret":"SECRET"}]
# We'll also have to edit the docker-compose.yml file to pass the guest_accounts.json to the container.
$ vim docker-compose.yml
version: "3"

services:

  nitter:
    image: ghcr.io/privacydevel/nitter:master
    container_name: nitter
    ports:
      - "8080:8080" # Replace with "8080:8080" if you don't use a reverse proxy. 
    volumes:
      - ./nitter.conf:/src/nitter.conf:Z,ro
      - ./guest_accounts.json:/src/guest_accounts.json:Z,ro
    depends_on:
      - nitter-redis
    restart: unless-stopped
    healthcheck:
      test: wget -nv --tries=1 --spider http://127.0.0.1:8080/Jack/status/20 ||                                                                                                  exit 1
      interval: 30s
      timeout: 5s
      retries: 2
    user: "998:998"
    read_only: true
    security_opt:
      - no-new-privileges:true
    cap_drop:
      - ALL

  nitter-redis:
    image: redis:6-alpine
    container_name: nitter-redis
    command: redis-server --save 60 1 --loglevel warning
    volumes:
      - nitter-redis:/data
    restart: unless-stopped
    healthcheck:
      test: redis-cli ping
      interval: 30s
      timeout: 5s
      retries: 2
    user: "999:1000"
    read_only: true
    security_opt:
      - no-new-privileges:true
    cap_drop:
      - ALL

volumes:
  nitter-redis:

$ vim nitter.conf # Now you can edit the nitter.conf file. I won't be going into it as it is fairly straightforward.
$ docker-compose up -d

And voila! Now if you go to your server’s IP on port 8080, you will be greeted by Nitter. Isn’t that awesome?

Thanks to Phin for helping me set it up.