gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

host-account-domain.md (4774B)


      1 # Split-domain deployments
      2 
      3 This guide explains how to have usernames like `@me@example.org` but run the GoToSocial instance itself on a subdomain like `social.example.org`. Configuring this type of deployment layout **must** be done before starting GoToSocial for the first time.
      4 
      5 !!! danger
      6     You cannot change your domain layout after you've federated with someone. Servers are going to get confused and you'll need to convince the admin of every instance that's federated with you before to mess with their database to resolve it. It also requires regenerating the database on your side to create a new instance account and pair of encryption keys.
      7 
      8 ## Background
      9 
     10 The way ActivityPub implementations discover how to map your account domain to your host domain is through a protocol called [webfinger](https://www.rfc-editor.org/rfc/rfc7033). This mapping is typically cached by servers and hence why you can't change it after the fact.
     11 
     12 It works by doing a request to `https://<account domain>/.well-known/webfinger?resource=acct:@me@example.org`. At this point, a server can return a redirect to where the actual webfinger endpoint is, `https://<host domain>/.well-known/webfinger?resource=acct:@me@example.org` or may respond directly. The JSON document that is returned informs you what the endpoint to query is for the user:
     13 
     14 ```json
     15 {
     16   "subject": "acct:me@example.org",
     17   "aliases": [
     18     "https://social.example.org/users/me",
     19     "https://social.example.org/@me"
     20   ],
     21   "links": [
     22     {
     23       "rel": "http://webfinger.net/rel/profile-page",
     24       "type": "text/html",
     25       "href": "https://social.example.org/@me"
     26     },
     27     {
     28       "rel": "self",
     29       "type": "application/activity+json",
     30       "href": "https://social.example.org/users/me"
     31     }
     32   ]
     33 }
     34 ```
     35 
     36 ActivityPub clients and servers will now use the entry from the `links` array with `rel` `self` and `type` `application/activity+json` to query for further information, like where the `inbox` is located to federated messages to.
     37 
     38 ## Configuration
     39 
     40 There are 2 configuration settings you'll need to concern yourself with:
     41 
     42 * `host`, the domain the API will be served on and what clients and servers will end up using when talking to your instance
     43 * `account-domain`, the domain user accounts will be created on
     44 
     45 In order to achieve the setup as described in the introduction, you'll need to set these two configuration options accordingly:
     46 
     47 ```yaml
     48 host: social.example.org
     49 account-domain: example.org
     50 ```
     51 
     52 !!! info
     53     The `host` must always be the DNS name that your GoToSocial instance runs on. It does not affect the IP address the GoToSocial instance binds to. That is controlled with `bind-address`.
     54 
     55 ## Reverse proxy
     56 
     57 When using a [reverse proxy](../getting_started/reverse_proxy/index.md) you'll need to ensure you're set up to handle traffic on both of those domains. You'll need to redirect a few endpoints from the account domain to the host domain.
     58 
     59 Redirects are typically used so that the change of domain can be detected client side. The endpoints to redirect from the account domain to the host domain are:
     60 
     61 * `/.well-known/webfinger`
     62 * `/.well-known/host-meta`
     63 * `/.well-known/nodeinfo`
     64 
     65 !!! tip
     66     Do not proxy or redirect requests to the API endpoints, `/api/...`, from the account domain to the host domain. This will confuse heuristics some clients use to detect a split-domain deployment resulting in broken login flows and other weird behaviour.
     67 
     68 ### nginx
     69 
     70 In order to configure the redirect, you'll need to configure it on the account domain. Assuming the account domain is `example.org` and the host domain is `social.example.org`, the following configuration snippet showcases how to do this:
     71 
     72 ```nginx
     73 server {
     74   server_name example.org;
     75 
     76   location /.well-known/webfinger {
     77     rewrite ^.*$ https://social.example.org/.well-known/webfinger permanent;
     78   }
     79 
     80   location /.well-known/host-meta {
     81       rewrite ^.*$ https://social.example.org/.well-known/host-meta permanent;
     82   }
     83 
     84   location /.well-known/nodeinfo {
     85       rewrite ^.*$ https://social.example.org/.well-known/nodeinfo permanent;
     86   }
     87 }
     88 ```
     89 
     90 ### Traefik
     91 
     92 If `example.org` is running on [Traefik](https://doc.traefik.io/traefik/), we could use labels similar to the following to setup the redirect.
     93 
     94 ```yaml
     95 myservice:
     96   image: foo
     97   # Other stuff
     98   labels:
     99     - 'traefik.http.routers.myservice.rule=Host(`example.org`)'
    100     - 'traefik.http.middlewares.myservice-gts.redirectregex.permanent=true'
    101     - 'traefik.http.middlewares.myservice-gts.redirectregex.regex=^https://(.*)/.well-known/(webfinger|nodeinfo|host-meta)$$'
    102     - 'traefik.http.middlewares.myservice-gts.redirectregex.replacement=https://social.$${1}/.well-known/$${2}'
    103     - 'traefik.http.routers.myservice.middlewares=myservice-gts@docker'
    104 ```