Joomaen

Joomaen's xlog

Joomaen
tg_channel
jike

GoToSocial Setup Steps

GoToSocial is a lightweight, low-resource ActivityPub social network server that is compatible with Mastodon and can be used to build a decentralized social platform.

pic

Background#

I previously set it up once, but used it less frequently. Now I've changed it to a shorter domain, directly using the subdomain zyg.im (previously it was a subdomain gts.joomaen.top).

According to ChatGPT's response, GoToSocial can change the domain, but it seems that the official documentation suggests otherwise. Anyway, I just set up a new one directly, and this time I want to keep using it.

Preparation#

  • A VPS with Docker and Docker Compose installed
  • A domain name (subdomain is also acceptable)
  • A reverse proxy server (Nginx, Caddy, etc., I am using OpenResty on 1Panel)
    I am using Docker Compose to set it up, which is more flexible. Just find any directory, and the mounted directory will be in its subdirectory, making it easy to migrate and back up.

Setup Steps#

  1. Create a new folder in your preferred location on the VPS as a working directory to store the docker-compose file and a directory to store GoToSocial data. I am in /opt, enter this directory:
mkdir -p /opt/gotosocial/data

cd /opt/gotosocial
  1. Use wget to get the latest docker-compose.yaml
wget https://raw.githubusercontent.com/superseriousbusiness/gotosocial/main/example/docker-compose/docker-compose.yaml
  1. Modify docker-compose.yaml as needed, open it with your preferred editor
vim docker-compose.yaml
1. Change the GTS_HOST environment variable to the domain name you are running GoToSocial on.
2. Uncomment the timezone and change it to TZ: Asia/Shanghai
3. By default, the Dockerized GoToSocial runs as Linux user/group 1000:1000, but I found it didn't work, so I changed it to the root user: user: 0:0
4. For the port, keep only - "8080:8080", I changed it to 8280 because I am using a reverse proxy and do not need to configure LetsEncrypt certificates here.

4. Here is my docker-compose.yml

version: "3.3"

services:
  gotosocial:
    image: superseriousbusiness/gotosocial:latest
    container_name: gotosocial
    user: 0:0
    networks:
      - gotosocial
    environment:
      # Change this to your actual host value.
      GTS_HOST: zyg.im
      GTS_DB_TYPE: sqlite
      # Path in the GtS Docker container where
      # the sqlite.db file will be stored.
      GTS_DB_ADDRESS: /gotosocial/storage/sqlite.db
      # Change this to true if you're not running
      # GoToSocial behind a reverse proxy.
      GTS_LETSENCRYPT_ENABLED: "false"
      # Set your email address here if you
      # want to receive letsencrypt notices.
      GTS_LETSENCRYPT_EMAIL_ADDRESS: ""
      # Path in the GtS Docker container where the
      # Wazero compilation cache will be stored.
      GTS_WAZERO_COMPILATION_CACHE: /gotosocial/.cache
      ## For reverse proxy setups:
      GTS_TRUSTED_PROXIES: "172.26.0.1/16"
      ## Set the timezone of your server:
      TZ: Asia/Shanghai
    ports:
      - "8280:8080"
      ## For letsencrypt:
      #- "80:80"
      ## For reverse proxy setups:
      #- "127.0.0.1:8280:8080"
    volumes:
      # Your data volume, for your
      # sqlite.db file and media files.
      - ./data:/gotosocial/storage
      # OPTIONAL: To mount volume for the WAZERO
      # compilation cache, for speedier restart
      # times, uncomment the below line:
      - ./.cache:/gotosocial/.cache
    restart: "always"

networks:
  gotosocial:
    ipam:
      driver: default
  1. Start GoToSocial
docker-compose up -d
  1. Create a user
# Change the following command to your own username, email, strong password

docker exec -it gotosocial /gotosocial/gotosocial admin account create --username YOUR_USERNAME --email YOUR@EMAIL.COM --password 'SOME_VERY_GOOD_PASSWD'

# The following command will promote the user to admin

docker exec -it gotosocial /gotosocial/gotosocial admin account promote --username YOUR_USERNAME
  1. Configure the reverse proxy port and certificates. I am using 1Panel, which makes it easy to configure. You can also use acme.sh. If using OpenResty on 1Panel, set the HTTP option in HTTPS to HTTP accessible directly. If it is set to Automatically redirect HTTP to HTTPS, you will encounter a circular redirection issue.
  2. You can now access your domain, and if you see the GoToSocial interface, it means the setup was successful.

Usage#

GoToSocial does not have a web interface by default and only provides backend services, which is why it consumes fewer resources compared to Mastodon. GoToSocial is compatible with Mastodon clients. I prefer using the web version and recommend Elk. Just enter your domain and authorize login using your email and password.
For mobile, you can use the official Mastodon app or third-party applications.

Summary#

Setting up a program that can connect to ActivityPub is very interesting and a necessary attempt, as the data is completely in your hands. I previously thought that ActivityPub was not completely decentralized because it consists of multiple instances forming a federation. Compatible programs include Mastodon, Pleroma, Misskey, etc. Even the lowest resource-consuming Pleroma is not easy for ordinary people to set up, so if everyone wants to use it, they can only go to someone else's server. Large instances are undoubtedly another centralized Weibo, while small instances have the risk of shutting down at any time, as they are not paid services. Having a self-hosted instance becomes very important. Of course, in a more extreme case, VPS providers may also go out of business. The ideal situation is for everyone to run their own instance on their home computers, keeping all data local. This can be achieved through Cloudflare Tunnel for access anywhere.

I have also been exploring decentralized storage like IPFS and have placed my blog on IPFS for multiple backups and domains, but this can only host static websites.

One issue with self-hosting GoToSocial is that there is only one user, making it impossible to discover other users directly. You can only manually search and wait for the server to connect with other users' servers to obtain content. Initially, you have to find people to follow, and later you can follow others based on their follow lists, which will increase over time.

I was using Nostr for a while, but I found it had some issues. When checking my posts, many were missing. I think it was because I frequently changed relays early on, causing posts to be stored on different relays. Some relays I haven't added now, so I can't retrieve the records. Later, I set up my own Nostr relay, which resolved many of these issues.

I want to use this GoToSocial instance as my posting place, while Nostr can be used for chatting with online friends. Using it for a few years and looking back will be very interesting.


References:

  1. Container - GoToSocial Documentation
  2. Create User - GoToSocial Documentation
  3. Self-hosted Gotosocial | An ActivityPub Federated Social Network Program - Independent World | Effective Notes
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.