YJK

独立世界

Independent World
twitter
telegram

Self-built Gotosocial | An ActivityPub federated social networking program

GoToSocial is an ActivityPub social network server written in Golang. It is a lightweight and secure entry point to a federated social network that allows users to stay connected, post, and share images, articles, and other content. GoToSocial emphasizes user privacy and freedom, does not track user behavior, and does not collect their data to show ads.

Using GoToSocial allows users to enter the world of federated social networks, which is a protocol-based social network structure that enables users to follow, communicate, and share content across different social network instances. This structure allows users to freely choose their social network platform while avoiding market monopolization by any single platform. Users can follow and interact across different instances, which better protects their privacy and freedom.

Using GoToSocial also helps avoid being influenced by ads and recommendation algorithms, as GoToSocial does not use these algorithms. The timeline in GoToSocial is sorted by publication time, and users can customize their timeline and experience through the people they follow and their interaction methods. Additionally, the user experience in GoToSocial is not based on user engagement and stickiness but rather on user interests and interaction methods. This design allows users to explore and discover content more freely, without being influenced by platform algorithms.

In summary, using GoToSocial allows users to join the world of federated social networks, protect their privacy and freedom, avoid being influenced by ads and recommendation algorithms, and explore and discover content that interests them.

—— From ChatGPT

GoToSocial is a very lightweight (so lightweight that it doesn't even have a user interface and requires third-party programs to log in, compatible with Mastodon apps) ActivityPub federated social network program. Building your own GoToSocial can prevent your information from being lost due to the closure of the instance you are on or other unforeseen circumstances.


1. Usage:#

Modify Personal Information#

Visit https://social.example.com/settings and log in with your username and password to make changes.

Post Tweets#

You can post, browse, and follow through third-party apps, and you can use the Mastodon client for this:

2. Setup Tutorial:#

1/ Install on Your Own VPS#

Install Docker

curl -L get.docker.com | bash

Create installation directory

mkdir -p /var/www/gotosocial/data && cd /var/www/gotosocial

Configure docker-compose.yaml file

nano docker-compose.yaml

Change social.example.com below to your own domain name and paste it in

version: "3.3"

services:
  gotosocial:
    image: superseriousbusiness/gotosocial:latest
    container_name: gotosocial
    user: 1000:1000
    networks:
      - gotosocial
    environment:
      GTS_HOST: social.example.com
      GTS_DB_TYPE: sqlite
      GTS_DB_ADDRESS: /gotosocial/storage/sqlite.db
      GTS_LETSENCRYPT_ENABLED: "false"
    ports:
      - "127.0.0.1:8080:8080"
    volumes:
      - ./data:/gotosocial/storage
    restart: "always"

networks:
  gotosocial:
    ipam:
      driver: default

Run

docker compose up -d

Create user

docker exec -it gotosocial /gotosocial/gotosocial admin account create --username YOUR_USERNAME --email [email protected] --password 'SOME_VERY_GOOD_PASSWD'

Set administrator

docker exec -it gotosocial /gotosocial/gotosocial admin account promote --username YOUR_USERNAME

Install Nginx

# For Debian/Ubuntu as an example

apt install -y lsb-release ca-certificates apt-transport-https curl gnupg dpkg
 
curl -sS https://n.wtf/public.key | gpg --dearmor > /usr/share/keyrings/n.wtf.gpg
 
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/n.wtf.gpg] https://mirror-cdn.xtom.com/sb/nginx/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/n.wtf.list
 
apt update
 
apt install nginx-extras -y

Install ACME.SH

curl -L get.acme.sh | bash

Restart the terminal, create Nginx configuration file

nano /etc/nginx/conf.d/gotosocial.conf

Paste the following content

server {
  listen 80;
  listen [::]:80;
  server_name social.example.com;
  root /var/www/gotosocial;
  location /.well-known/acme-challenge/ { allow all; }
  location / { return 301 https://$host$request_uri; }
}

Restart Nginx nginx -s reload, point the domain name to the VPS's IP address, and generate the SSL certificate

acme.sh --issue -d social.example.com -w /var/www/gotosocial --server letsencrypt

The generated certificate looks like this

[Thu 12 Nov 2020 07:16:28 AM EST] Your cert is in  /root/.acme.sh/social.example.com/social.example.com.cer
[Thu 12 Nov 2020 07:16:28 AM EST] Your cert key is in  /root/.acme.sh/social.example.com/social.example.com.key
[Thu 12 Nov 2020 07:16:30 AM EST] The intermediate CA cert is in  /root/.acme.sh/social.example.com/ca.cer
[Thu 12 Nov 2020 07:16:30 AM EST] And the full chain certs is there:  /root/.acme.sh/social.example.com/fullchain.cer

We need the following

/root/.acme.sh/social.example.com/fullchain.cer
/root/.acme.sh/social.example.com/social.example.com.key

Edit the Nginx configuration file again

nano /etc/nginx/conf.d/gotosocial.conf

Paste the following content

map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      close;
}

server {
  listen 80;
  listen [::]:80;
  server_name social.example.com;
  root /var/www/gotosocial;
  location /.well-known/acme-challenge/ { allow all; }
  location / { return 301 https://$host$request_uri; }
}

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name social.example.com;

  ssl_protocols TLSv1.2 TLSv1.3;
  ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5;
  ssl_prefer_server_ciphers on;
  ssl_session_cache shared:SSL:10m;
  ssl_session_tickets off;

  ssl_certificate /root/.acme.sh/social.example.com/fullchain.cer;
  ssl_certificate_key /root/.acme.sh/social.example.com/social.example.com.key;

  keepalive_timeout    70;
  sendfile             on;
  client_max_body_size 80m;

  root /var/www/gotosocial;

  gzip on;
  gzip_disable "msie6";
  gzip_vary on;
  gzip_proxied any;
  gzip_comp_level 6;
  gzip_buffers 16 8k;
  gzip_http_version 1.1;
  gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml image/x-icon;

  location / {
    proxy_pass http://127.0.0.1:8080;
    proxy_set_header Host $host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
  }

Restart Nginx nginx -s reload, and you can now access your GoToSocial.

2/ Free Installation on Fly.io#

Preparation:

  • Register for a Fly.io account and bind a card (to avoid abuse);
  • Register for Cloudflare and enable R2, enabling R2 requires binding a card. Create a storage bucket and create an API token.
  • Register for a Yugabyte account and create a database, select the region tokyo, remember to save the username and password during the creation process, and after the creation is successful, click the connect button in the upper right corner to select Connect to your Application - Parameters to get the connection information. We need the Host, Port, and Database.

Install flyctl

# Linux
curl -L https://fly.io/install.sh | sh

# macOS
curl -L https://fly.io/install.sh | sh

# Windows, you need to enable RemoteSigned: run as administrator Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
powershell -Command "iwr https://fly.io/install.ps1 -useb | iex"

Log in

flyctl auth login

# If login fails, use
# flyctl auth login -i 
# Enter username and password to log in

Create installation directory

mkdir ~/gotosocial && cd gotosocial

Create APP

flyctl launch --name YOURAPPNAME --image=superseriousbusiness/gotosocial:latest --region nrt --no-deploy

Create storage volume, 1G is sufficient

flyctl volumes create social_data --region nrt --size 1

Edit the fly.toml configuration file in the current directory with the following configuration (the following configuration file content has been revised according to the fly.io v2 deployment platform)

app = "yjksocial"
primary_region = "nrt"

[build]
  image = "superseriousbusiness/gotosocial:latest"

[env]
  GTS_HOST = "social.example.com"
  GTS_DB_TYPE = "postgres"
  GTS_DB_PORT = 5433
  GTS_DB_ADDRESS = "the previously recorded database Host"
  GTS_DB_USER = "admin"
  GTS_DB_PASSWORD = "the previously recorded database user password"
  GTS_DB_DATABASE = "yugabyte"
  GTS_DB_TLS_MODE = "enable"
  GTS_LETSENCRYPT_ENABLED = "false"
  GTS_STORAGE_BACKEND = "s3"
  GTS_STORAGE_S3_ENDPOINT = "Cloudflare R2 API address, remember to remove “/bucket name”"
  GTS_STORAGE_S3_ACCESS_KEY = "Cloudflare R2 API ACCESS KEY"
  GTS_STORAGE_S3_SECRET_KEY = "Cloudflare R2 API SECRET KEY"
  GTS_STORAGE_S3_BUCKET = "Cloudflare R2 bucket name"
  GTS_STORAGE_S3_PROXY = true

[mounts]
  source="social_data"
  destination="/gotosocial/storage"

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = false
  auto_start_machines = true
  min_machines_running = 1
  processes = ["app"]

Start APP

flyctl deploy

If you can successfully access https://YOURAPPNAME.fly.dev, it means the deployment was successful.

Bind the domain name, set your domain CNMAE to YOURAPPNAME.fly.dev, and then run

flyctl certs add social.example.com

Wait a few minutes.

Create users and set administrators

# Execute in the directory of the fly.toml file
flyctl ssh console
# Create user
/gotosocial/gotosocial admin account create --username YOUR_USERNAME --email [email protected] --password 'SOME_VERY_GOOD_PASSWD'

# Set administrator
/gotosocial/gotosocial admin account promote --username YOUR_USERNAME
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.