### Example Tracing Setup with Docker Compose Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/advanced/tracing_display=source This snippet refers to an example tracing setup using docker-compose in the 'example/tracing' directory. It's suitable for local development and provides a starting point for production setups. ```bash docker-compose up -d ``` -------------------------------- ### Starting GoToSocial Server with Command-Line Flags Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/configuration/index Provides an example of configuring GoToSocial by directly passing a value as a command-line flag when starting the server. This method overrides values set in configuration files or environment variables. ```bash gotosocial server start --media-image-max-size 2097152 ``` -------------------------------- ### Wazero Cache Configuration Example Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/configuration/index Shows how to set the GTS_WAZERO_COMPILATION_CACHE environment variable to specify a directory for storing compiled Wazero modules. This speeds up GoToSocial startup by caching media processing binaries. The example demonstrates setting the variable and then starting the server. ```bash GTS_WAZERO_COMPILATION_CACHE=~/gotosocial/.cache ./gotosocial --config-path ./config.yaml server start ``` -------------------------------- ### Start GoToSocial Server with Config File Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/configuration/index This command starts the GoToSocial server, specifying the path to a YAML or JSON configuration file. This is the primary method for providing custom settings to the GoToSocial instance. ```bash gotosocial --config-path ./config.yaml server start ``` -------------------------------- ### Mounting Config File with Podman/Docker CLI Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/configuration/index Shows how to start a GoToSocial container using Podman or Docker CLI, mounting a local configuration file and specifying its path either via the command-line argument or an environment variable. ```bash podman run \ --mount type=bind,source=/path/on/the/host/to/config.yaml,destination=/gotosocial/config.yaml,readonly \ docker.io/superseriousbusiness/gotosocial:latest \ --config-path /gotosocial/config.yaml ``` ```bash podman run \ --mount type=bind,source=/path/on/the/host/to/config.yaml,destination=/gotosocial/config.yaml,readonly \ --env 'GTS_CONFIG_PATH=/gotosocial/config.yaml' \ docker.io/superseriousbusiness/gotosocial:latest ``` -------------------------------- ### ActivityPub AnnounceApproval Object Example Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/federation/interaction_policy An example of an 'AnnounceApproval' object, an extension of ActivityStreams. This object indicates that an 'Announce' (boost) interaction has been approved, referencing the specific 'Announce' object and the 'target' post. ```json { "@context": [ "https://www.w3.org/ns/activitystreams", "https://gotosocial.org/ns" ], "attributedTo": "https://example.org/users/post_author", "id": "https://example.org/users/post_author/approvals/01J0K2YXP9QCT5BE1JWQSAM3B6", "object": "https://somewhere.else.example.org/users/someone/boosts/01JMPKG79EAH0NB04BHEM9D20N", "target": "https://example.org/users/post_author/statuses/01JJYV141Y5M4S65SC1XCP65NT", "type": "AnnounceApproval" } ``` -------------------------------- ### ActivityPub ReplyApproval Object Example Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/federation/interaction_policy An example of a 'ReplyApproval' object, extending ActivityStreams. This object confirms that a 'Reply' interaction has been approved. It specifies the approved 'Reply' object and the 'target' post that was replied to. ```json { "@context": [ "https://www.w3.org/ns/activitystreams", "https://gotosocial.org/ns" ], "attributedTo": "https://example.org/users/post_author", "id": "https://example.org/users/post_author/approvals/01J0K2YXP9QCT5BE1JWQSAM3B6", "object": "https://somewhere.else.example.org/users/someone/statuses/01J17XY2VXGMNNPH1XR7BG2524", "target": "https://example.org/users/post_author/statuses/01JJYV141Y5M4S65SC1XCP65NT", "type": "ReplyApproval" } ``` -------------------------------- ### Example: Creating a GoToSocial Admin Account Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/admin/cli Illustrates how to use the `gotosocial admin account create` command with specific username, email, password, and configuration path. ```bash gotosocial admin account create \ --username some_username \ --email someuser@example.org \ --password 'somelongandcomplicatedpassword' \ --config-path config.yaml ``` -------------------------------- ### Provision TLS Certificates with Certbot Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/getting_started/reverse_proxy/nginx_display=source This command initiates the Certbot process to automatically provision and install TLS/SSL certificates for your GoToSocial instance, enabling HTTPS. Follow the on-screen prompts for configuration. ```bash sudo certbot --nginx ``` -------------------------------- ### Install and Parse AppArmor Policy for GoToSocial Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/advanced/security/sandboxing This snippet shows how to download the example AppArmor policy file for GoToSocial, install it to the system's AppArmor directory, and then parse it to activate the policy. It assumes you have `curl` and `sudo` installed. ```bash $ curl -LO 'https://codeberg.org/superseriousbusiness/gotosocial/raw/main/example/apparmor/gotosocial' $ sudo install -o root -g root gotosocial /etc/apparmor.d/gotosocial $ sudo apparmor_parser -Kr /etc/apparmor.d/gotosocial ``` -------------------------------- ### Setting Environment Variable Arrays Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/configuration/index_display=source Demonstrates how to set configuration options that accept arrays using environment variables. Values should be provided as a comma-separated list. ```bash GTS_INSTANCE_LANGUAGES="nl,de,fr,en" ``` -------------------------------- ### GoToSocial Configuration File Example (YAML) Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/configuration/syslog An example of the GoToSocial configuration file in YAML format. It shows default values and comments for various settings, including syslog and advanced throttling, intended to guide user configuration. ```yaml # example/config.yaml syslog-enabled: false syslog-protocol: "udp" syslog-address: "localhost:514" # ... other settings ... # AdvancedThrottlingRetryAfter: Set when to retry after advanced throttling. If this is empty, GoToSocial will retry after 15 minutes. # advanced-throttling-retry-after: "" ``` -------------------------------- ### Enable NGINX Site Configuration and Test Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/getting_started/reverse_proxy/nginx These commands enable the newly created NGINX site configuration by creating a symbolic link and then test the NGINX configuration for syntax errors. If the test is successful, it indicates that NGINX is ready to load the new configuration. ```bash sudo mkdir -p /etc/nginx/sites-enabled sudo ln -s /etc/nginx/sites-available/yourgotosocial.url.conf /etc/nginx/sites-enabled/ sudo nginx -t ``` -------------------------------- ### Install Caddy 2 on Debian/Ubuntu Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/getting_started/reverse_proxy/caddy Installs Caddy 2 on Debian-based systems using their custom repository. This method ensures you get the latest stable version and allows for automatic Let's Encrypt certificate management. ```bash sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list sudo apt update sudo apt install caddy ``` -------------------------------- ### Stop GoToSocial Systemd Service Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/getting_started/reverse_proxy/nginx_display=source This command stops the GoToSocial service if it is managed by systemd. This is a preliminary step before modifying its configuration. ```bash sudo systemctl stop gotosocial ``` -------------------------------- ### Apache Configuration Commands Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/getting_started/reverse_proxy/apache-httpd_display=source This section provides essential bash commands for managing Apache HTTP Server configurations. It includes creating directories for available sites, creating symbolic links to enable sites, testing configuration syntax, and restarting the Apache service to apply changes. These commands are crucial for implementing the virtual host setup. ```bash sudo mkdir -p /etc/apache2/sites-available sudoedit /etc/apache2/sites-available/example.com.conf ``` ```bash sudo mkdir /etc/apache2/sites-enabled sudo ln -s /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-enabled/ ``` ```bash sudo apachectl -t ``` ```bash sudo systemctl restart apache2 ``` -------------------------------- ### Create NGINX Site Configuration Directory Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/getting_started/reverse_proxy/nginx_display=source This bash command creates the directory '/etc/nginx/sites-available' if it does not already exist. This directory is used to store NGINX virtual host configuration files. ```bash sudo mkdir -p /etc/nginx/sites-available ``` -------------------------------- ### ActivityPub Accept Activity Example Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/federation/interaction_policy An example of an 'Accept' Activity in ActivityStreams format. This activity is sent by the author of a post to acknowledge an interaction, with the interaction URI in 'object' and an approval URI in 'result'. ```json { "@context": "https://www.w3.org/ns/activitystreams", "actor": "https://example.org/users/post_author", "cc": [ "https://www.w3.org/ns/activitystreams#Public", "https://example.org/users/post_author/followers" ], "to": "https://somewhere.else.example.org/users/someone", "id": "https://example.org/users/post_author/activities/accept/01J0K2YXP9QCT5BE1JWQSAM3B6", "object": "https://somewhere.else.example.org/users/someone/statuses/01J17XY2VXGMNNPH1XR7BG2524", "result": "https://example.org/users/post_author/reply_approvals/01JMMGABRDNA9G9BDNYJR7TC8D", "type": "Accept" } ``` -------------------------------- ### Enable Apache Site and Test Configuration Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/getting_started/reverse_proxy/apache-httpd These commands enable a new Apache virtual host configuration by creating a symbolic link and then test the Apache configuration for syntax errors. If the test passes ('Syntax OK'), Apache is restarted to apply the changes. ```bash sudo mkdir /etc/apache2/sites-enabled sudo ln -s /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-enabled/ sudo apachectl -t sudo systemctl restart apache2 ``` -------------------------------- ### Mounting Config File in Docker Compose Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/configuration/index Demonstrates how to configure GoToSocial within a Docker Compose setup by mounting a local configuration file to a path inside the container and specifying it via the command or environment variable. ```yaml services: gotosocial: command: ["--config-path", "/gotosocial/config.yaml"] volumes: - type: bind source: /path/on/the/host/to/config.yaml target: /gotosocial/config.yaml read_only: true ``` ```yaml services: gotosocial: environment: GTS_CONFIG_PATH: /gotosocial/config.yaml volumes: - type: bind source: /path/on/the/host/to/config.yaml target: /gotosocial/config.yaml read_only: true ``` -------------------------------- ### Link Nginx Configuration File Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/getting_started/reverse_proxy/nginx_display=source This command links the GoToSocial Nginx configuration file to the directory where Nginx looks for active site configurations. Ensure you replace 'yourgotosocial.url' with your actual domain name. ```bash sudo mkdir -p /etc/nginx/sites-enabled sudo ln -s /etc/nginx/sites-available/yourgotosocial.url.conf /etc/nginx/sites-enabled/ ``` -------------------------------- ### GoToSocial Admin Import Example Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/admin/cli This example demonstrates how to use the 'gotosocial admin import' command with the required file path and an optional configuration file path. The command imports data from 'example.json' using settings from 'config.yaml'. ```bash gotosocial admin import --path example.json --config-path config.yaml ``` -------------------------------- ### Edit NGINX Site Configuration File Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/getting_started/reverse_proxy/nginx_display=source This command opens the NGINX site configuration file for editing using the default system editor. Replace 'yourgotosocial.url' with your actual GoToSocial domain name. ```bash sudoedit /etc/nginx/sites-available/yourgotosocial.url.conf ``` -------------------------------- ### Backup Data Format Example (JSON Lines) Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/admin/backup_and_restore This snippet demonstrates the expected format of the backup file generated by the GoToSocial CLI. Each line represents a distinct JSON object containing account data, including user credentials and cryptographic keys necessary for federation. ```json {"type":"account","id":"01F8MH5NBDF2MV7CTC4Q5128HF","createdAt":"2021-08-31T12:00:53.985645Z","username":"1happyturtle","locked":true,"language":"en","uri":"http://localhost:8080/users/1happyturtle","url":"http://localhost:8080/@1happyturtle","inboxURI":"http://localhost:8080/users/1happyturtle/inbox","outboxURI":"http://localhost:8080/users/1happyturtle/outbox","followingUri":"http://localhost:8080/users/1happyturtle/following","followersUri":"http://localhost:8080/users/1happyturtle/followers","featuredCollectionUri":"http://localhost:8080/users/1happyturtle/collections/featured","actorType":"Person","privateKey":"-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAzLP7oyyR+BU9ejn0CN9K+WpX3L37pxUcCgZAGH5lf3cGPZjzausf\nsFME94OjVyzw3K5M2beDkZ4E+Fak46NLtakLB1yovy9jKtj4Y4txHoMvRJLzeUPx\ndfeXtpx2d3FDj++Uq4DEE0BhbePXhTGJWaNdC9MQmWKghJnCS5mrnFkdpEFxjUz9\nl0UHl2Z4wppxPdpt7FyevcdfKqzGsAA3BxTM0dg47ZJWjtcvfCiSYpAKFNJYfKhK\nn9T3ezZgr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dUJVNeKvBoss4sMP0phqxwf0eWV3ur0\ncjIQB+TpGGikLVdRVuGY/UXHKe9AjoHBva8B3aTpB3lbnbNJBXZbIc1uYq3sa5w7\nXWWUAQKBgH3yW73RRpQNcc9hTUssomUsnQQgHxpfWx5tNxqod36Ytd9EKBh3NqUZ\nvPcH6gdh7mcnNaVNTtQOHLHsbPfBK/pqvb3MAsdlokJcQz8MQJ9SGBBPY6PaGw8z\nq/ambaQykER6dwlXTIlU20uXY0bttOL/iYjKmgo3vA66qfzS6nsg\n-----END RSA PRIVATE KEY-----\n","publicKey":"-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAzLP7oyyR+BU9ejn0CN9K+WpX3L37pxUcCgZAGH5lf3cGPZjzausf\nsFME94OjVyzw3K5M2beDkZ4E+Fak46NLtakLB1yovy9jKtj4Y4txHoMvRJLzeUPx\ndfeXtpx2d3FDj++Uq4DEE0BhbePXhTGJWaNdC9MQmWKghJnCS5mrnFkdpEFxjUz9\nl0UHl2Z4wppxPdpt7FyevcdfKqzGsAA3BxTM0dg47ZJWjtcvfCiSYpAKFNJYfKhK\nn9T3ezZgrLsF+o0IpD23KxWe1X4d5lgJRU9T4FmLmbvyJKUnfgYXbSEvLUcq79Wb\nhgRcWwxWubjmWXgPGwzULVhhpYlwd2Cv3wIDAQAB\n-----END RSA PUBLIC KEY-----\n","publicKeyUri":"http://localhost:8080/users/1happyturtle#main-key"} ``` -------------------------------- ### Enabling GoToSocial Apache Site Configuration Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/getting_started/reverse_proxy/apache-httpd_display=source These bash commands enable the GoToSocial site configuration for Apache. It involves creating a symbolic link from the available sites configuration to the enabled sites directory. Remember to replace 'example.com' with your GoToSocial server's hostname. ```bash sudo mkdir /etc/apache2/sites-enabled sudo ln -s /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-enabled/ ``` -------------------------------- ### Nginx Configuration for GoToSocial with TLS Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/getting_started/reverse_proxy/nginx_display=source This Nginx configuration block sets up GoToSocial to run behind Nginx with HTTPS enabled. It includes proxying settings for GoToSocial, WebSocket support, and Certbot-managed SSL configurations. ```nginx server { server_name example.org; location / { # set to 127.0.0.1 instead of localhost to work around https://stackoverflow.com/a/52550758 proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; } client_max_body_size 40M; listen [::]:443 ssl; # managed by Certbot listen 443 ssl; # managed by Certbot http2 on; # managed by Certbot ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { if ($host = example.org) { return 301 https://$host$request_uri; } listen 80; listen [::]:80; server_name example.org; return 404; # managed by Certbot } ``` -------------------------------- ### Go Dependency Management and Build Commands Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/configuration/observability_and_metrics This snippet shows common commands for Go project development, including formatting code with `go fmt` and linting with `golangci-lint`. These are typically run as part of a pre-commit hook or CI/CD pipeline to ensure code quality and consistency. ```bash go fmt ./... golangci-lint run ``` -------------------------------- ### Example Featured Posts Collection (Multiple Notes) Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/federation/actors This JSON example demonstrates the structure of a user's featured posts collection when multiple 'Note' activities have been pinned. It includes the collection's ID, total number of items, and an ordered list of URIs for each pinned post. ```json { "@context": "https://www.w3.org/ns/activitystreams", "id": "https://example.org/users/some_user/collections/featured", "orderedItems": [ "https://example.org/users/some_user/statuses/01GS7VTYH0S77NNXTP6W4G9EAG", "https://example.org/users/some_user/statuses/01GSFY2SZK9TPCJFQ1WCCPGDRT", "https://example.org/users/some_user/statuses/01GSCXY70MZCBFMH5EKJW9ENC8" ], "totalItems": 3, "type": "OrderedCollection" } ``` -------------------------------- ### Test and Reload Nginx Configuration Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/getting_started/reverse_proxy/nginx_display=source After making changes to the Nginx configuration, it's crucial to test for syntax errors and then reload Nginx to apply the new settings. This ensures the server recognizes the updated configuration. ```bash sudo nginx -t sudo systemctl restart nginx ``` -------------------------------- ### Configure GoToSocial Port and Bind Address Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/getting_started/reverse_proxy/nginx_display=source This YAML snippet configures GoToSocial to disable built-in TLS provisioning and bind to a specific local address and port. This allows NGINX to handle TLS and external access. ```yaml letsencrypt-enabled: false port: 8080 bind-address: 127.0.0.1 ``` -------------------------------- ### PostgreSQL Database and User Creation (psql) Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/configuration/database These psql commands are used to create a PostgreSQL database and a user, granting the necessary privileges for GoToSocial to operate. It's crucial to use the `C.UTF-8` locale and `template0` for compatibility with ULIDs. ```sql create database gotosocial with locale 'C.UTF-8' template template0; create user gotosocial with password 'some_really_good_password'; grant all privileges on database gotosocial to gotosocial; ``` -------------------------------- ### Nginx Redirects for GoToSocial Split-Domain Source: https://codeberg.org/superseriousbusiness/gotosocial/src/branch/main/docs/advanced/host-account-domain This Nginx configuration sets up redirects on the account domain (`example.org`) to the host domain (`social.example.org`) for specific well-known endpoints. This is essential for correctly handling webfinger, host-meta, and nodeinfo requests in a split-domain setup. ```nginx server { server_name example.org; # account-domain location /.well-known/webfinger { rewrite ^.*$ https://social.example.org/.well-known/webfinger permanent; # host } location /.well-known/host-meta { rewrite ^.*$ https://social.example.org/.well-known/host-meta permanent; # host } location /.well-known/nodeinfo { rewrite ^.*$ https://social.example.org/.well-known/nodeinfo permanent; # host } } ```