snac.8 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978
  1. .Dd $Mdocdate$
  2. .Dt SNAC 8
  3. .Os
  4. .Sh NAME
  5. .Nm snac
  6. .Nd snac administration
  7. .Sh DESCRIPTION
  8. The
  9. .Nm
  10. daemon processes messages from other servers in the Fediverse
  11. using the ActivityPub protocol.
  12. .Pp
  13. This is the admin manual. For user operation, see
  14. .Xr snac 1 .
  15. For file and data formats, see
  16. .Xr snac 5 .
  17. .Ss Special cares about your snac you must know beforehand
  18. .Nm
  19. makes heavy use of hard links and link reference counts for its work, so
  20. don't even think of using it on a filesystem that doesn't support this
  21. feature. Most UNIX-like operating systems (Linux, the BSDs, the old DEC
  22. Ultrix machine in your grandfather basement, probably MacOS) support hard
  23. links on their native filesystems. Don't do fancy things like moving the
  24. subdirectories to different filesystems. Also, if you move your
  25. .Nm
  26. installation to another server, do it with a tool that keeps hard
  27. links, like
  28. .Xr tar 1
  29. or
  30. .Xr rsync 1
  31. with the -H switch. Remember:
  32. .Nm
  33. is a very UNIXy program that loves hard links.
  34. .Ss Building and Installation
  35. A C compiler must be installed in the system, as well as the development
  36. headers and libraries for OpenSSL (or compatible) and curl. To build
  37. .Nm ,
  38. run
  39. .Bd -literal -offset indent
  40. make
  41. .Ed
  42. .Pp
  43. And, after that, run as root
  44. .Bd -literal -offset indent
  45. make install
  46. .Ed
  47. .Ss Data storage Initialization
  48. Once
  49. .Nm
  50. is properly installed on the system, designate a directory where
  51. the server and user data are to be stored. This directory
  52. must not exist yet.
  53. .Nm
  54. must always be run as a regular user; you can create one for
  55. it or use your own. To initialize the data storage, execute
  56. .Bd -literal -offset indent
  57. snac init $HOME/snac-data
  58. .Ed
  59. .Pp
  60. A small set of questions will be asked regarding the installation,
  61. specially the host name it will run under, the local network address
  62. and port
  63. .Nm
  64. will listen to, the optional path prefix and possibly other things.
  65. .Pp
  66. Since version 2.57, if the 'network address' starts with /, it's
  67. assumed to be a UNIX-like socket (please take note that the http proxy
  68. must have full read and write access to this socket; this is a common
  69. pitfall. Permissions will break your heart).
  70. .Pp
  71. You can launch the
  72. .Nm
  73. process by running
  74. .Bd -literal -offset indent
  75. snac httpd $HOME/snac-data
  76. .Ed
  77. .Pp
  78. Log messages are sent to the standard error stream. By default, only
  79. relevant information is written there. You can increase the debugging
  80. level by editing the 'dbglevel' field in the
  81. .Pa server.json
  82. file or by setting a numeric value between 0 and 3 to the DEBUG
  83. environment variable, see below.
  84. .Pp
  85. If you operate a Linux systemd-enabled system, OpenBSD, FreeBSD or NetBSD, there are
  86. startup scripts and configuration data in the
  87. .Pa examples
  88. directory.
  89. For other operating systems, please read the appropriate documentation
  90. on how to install a daemon as a non-root service.
  91. .Ss Upgrading to a new version
  92. Sometimes, the data storage disk layout changes between versions. If there
  93. is such a change,
  94. .Nm
  95. will refuse to run and require an upgrade. Do this by running
  96. .Bd -literal -offset indent
  97. snac upgrade $HOME/snac-data
  98. .Ed
  99. .Pp
  100. Take special care to execute this upgrade operation without any
  101. .Nm
  102. processes serving on the same folder. You can break everything. I know
  103. this because Tyler knows this.
  104. .Pp
  105. .Ss Server Setup
  106. .Pp
  107. An http server with TLS and proxying support must already be
  108. installed and configured.
  109. .Nm
  110. runs as a daemon and listens on a TCP/IP socket, preferably
  111. on a local interface. It can serve the full domain or only
  112. a directory. The http server must be configured to route to the
  113. .Nm
  114. socket all related traffic and also the webfinger standard
  115. address. The Host header must be propagated.
  116. See the examples below.
  117. .Ss Adding Users
  118. .Pp
  119. Users must be created from the command line.
  120. You can do it by running
  121. .Bd -literal -offset indent
  122. snac adduser $HOME/snac-data
  123. .Ed
  124. .Pp
  125. All needed data will be prompted for. There is no artificial limit
  126. on the number of users that can be created.
  127. .Ss Customization
  128. The
  129. .Pa server.json
  130. configuration file allows some behaviour tuning:
  131. .Bl -tag -width tenletters
  132. .It Ic host
  133. The host name.
  134. .It Ic prefix
  135. The URL path prefix.
  136. .It Ic address
  137. The listen network address. If it starts with /, it's assumed to be
  138. a UNIX-like socket instead.
  139. .It Ic port
  140. The listen network port (unused if address is a UNIX socket).
  141. .It Ic dbglevel
  142. The debug level. An integer value, being 0 the less verbose (the default).
  143. .It Ic layout
  144. The disk storage layout version. Never touch this.
  145. .It Ic queue_retry_max
  146. Messages sent out are stored in a queue. If the posting of a messages fails,
  147. it's re-enqueued for later. This integer configures the maximum count of
  148. times the sending will be retried.
  149. .It Ic queue_retry_minutes
  150. The number of minutes to wait before the failed posting of a message is
  151. retried. This is not linear, but multiplied by the number of retries
  152. already done.
  153. .It Ic queue_timeout
  154. The maximum number of seconds to wait when sending a message from the queue.
  155. .It Ic queue_timeout_2
  156. The maximum number of seconds to wait when sending a message from the queue
  157. to those servers that went timeout in the previous retry. If you want to
  158. give slow servers a chance to receive your messages, you can increase this
  159. value (but also take into account that processing the queue will take longer
  160. while waiting for these molasses to respond).
  161. .It Ic def_timeline_entries
  162. This is the default timeline entries shown in the web interface.
  163. .It Ic max_timeline_entries
  164. This is the maximum timeline entries shown in the web interface.
  165. .It Ic timeline_purge_days
  166. Entries in the timeline older that this number of days are purged.
  167. If you don't want any timeline purging and enjoy your data drives
  168. fill up with old crap and finally burst in flames, you can disable
  169. purging by setting this to 0.
  170. .It Ic local_purge_days
  171. Same as before, but for the user-generated entries in the local timeline.
  172. .It Ic propagate_local_purge
  173. If this value is set to true, a Delete activity is generated for every
  174. purged local post and sent everywhere.
  175. .It Ic cssurls
  176. This is a list of URLs to CSS files that will be inserted, in this order,
  177. in the HTML before the user CSS. Use these files to configure the global
  178. site layout.
  179. .It Ic disable_cache
  180. If set to true, timeline caching is not done. This is only useful for
  181. debugging purposes; don't enable it unless you know what do you want, as
  182. it makes everything slower.
  183. .It Ic disable_openbsd_security
  184. If running under OpenBSD,
  185. .Nm
  186. makes use of the enhanced security functions
  187. .Xr unveil 2
  188. and
  189. .Xr pledge 2 .
  190. Setting this to true disables their usage. These functions limit severely
  191. what an intruder can do in case of a security vulnerability, so only enable
  192. this option if something is very broken.
  193. .It Ic num_threads
  194. By setting this value, you can specify the exact number of threads
  195. .Nm
  196. will use when processing connections. Values lesser than 4 will be ignored.
  197. .It Ic disable_email_notifications
  198. By setting this to true, no email notification will be sent for any user.
  199. .It Ic disable_inbox_collection
  200. By setting this to true, no inbox collection is done. Inbox collection helps
  201. being discovered from remote instances, but also increases network traffic.
  202. .It Ic http_headers
  203. If you need to add more HTTP response headers for whatever reason, you can
  204. fill this object with the required header/value pairs.
  205. .It Ic show_instance_timeline
  206. If this is set to true, the instance base URL will show a timeline with the latest
  207. user posts instead of the default greeting static page. If other information
  208. fields are set (see below), they are also shown.
  209. .It Ic admin_email
  210. The email address of the instance administrator (optional).
  211. .It Ic admin_account
  212. The user name of the instance administrator (optional).
  213. .It Ic title
  214. The name of the instance (optional).
  215. .It Ic short_description
  216. A textual short description about the instance (optional).
  217. .It Ic short_description_raw
  218. Whether to interpret short_descript as raw string or convert to HTML (optional).
  219. .It Ic fastcgi
  220. If set to true,
  221. .Nm
  222. will use the FastCGI interface to communicate with the upper level
  223. http server, that must be configured accordingly.
  224. .It Ic disable_history
  225. If set to true, history monthly snapshots are not served nor their links shown.
  226. .It Ic shared_inboxes
  227. This boolean value selects if shared inboxes are announced or not. Enabling
  228. shared inboxes helps (somewhat) in optimizing incoming traffic for instances
  229. with a large number of users.
  230. .It Ic min_account_age
  231. If this numeric value (in seconds) is set, any activity coming from an account
  232. that was created more recently than that will be rejected. This may be used
  233. to mitigate spam from automatically created accounts.
  234. .It Ic protocol
  235. This string value contains the protocol (schema) to be used in URLs. If not
  236. set, it defaults to "https". If you run
  237. .Nm
  238. as part of a hidden network like Tor or I2P that doesn't have a TLS /
  239. Certificate infrastructure, you need to set it to "http". Don't change it
  240. unless you know what you are doing.
  241. .It Ic hide_delete_post_button
  242. If set to true, the button to delete a post is not shown. It's not very
  243. useful and somewhat clutters the already crowded button space.
  244. .It Ic disable_block_notifications
  245. If set to true, notifications about 'Block' activities are never sent.
  246. .It Ic strict_public_timelines
  247. If set to true, public timelines only show posts and boosts originating
  248. from an account (no conversation trees).
  249. .It Ic proxy_media
  250. If set to true, links to all image, audio or video media from other accounts'
  251. posts will not be direct ones, but proxied by
  252. .Nm .
  253. This way, remote media servers will not see the user's IP, but the server one,
  254. improving privacy. Please take note that this will increase the server's incoming
  255. and outgoing traffic.
  256. .It Ic badlogin_retries
  257. If incorrect logins from a given IP address reach this count, subsequent attempts
  258. from it are rejected until the lock expires (default: 5 retries).
  259. .It Ic badlogin_expire
  260. The number of seconds a blocked IP address is ignored in login attempts
  261. (default: 300 seconds).
  262. .It Ic disable_sandbox
  263. This boolean toggle allows disabling Linux Landlock sandboxing. Confining a
  264. program in a sandbox limits the directories and resources it can use, so it's
  265. recommended for security. Support for Linux sandboxing must be compiled in, and you
  266. need at least a Linux kernel version 5.13.0.
  267. .It Ic max_public_entries
  268. The maximum number of entries (posts) to be returned in user RSS feeds and outboxes
  269. (default: 20).
  270. .It Ic max_attachments
  271. The maximum number of attachments per post (default: 4).
  272. .It Ic max_poll_options
  273. The maximum number of poll options in a poll (default: 8).
  274. .It Ic max_poll_option_length
  275. The maximum length of a single poll option (default: 60).
  276. .It Ic enable_svg
  277. Since version 2.73, SVG image attachments are hidden by default; you can enable
  278. them by setting this value to true.
  279. .It Ic smtp_url
  280. Since version 2.76, email notifications can be sent via direct connection to an
  281. SMTP server instead of the traditional behaviour of piping the message to
  282. .Pa /usr/sbin/sendmail .
  283. Set this value to the SMTP url to be used for sending email notifications
  284. (for example, smtp://localhost). It may include a port number if it's not running on
  285. the usual one, like in smtp://mail.example.com:587.
  286. .It Ic smtp_user
  287. .It Ic smtp_password
  288. To be filled if the SMTP server defined by the previous directive needs credentials.
  289. .It Ic rss_hashtag_poll_hours
  290. The periodic number of hours hashtag RSS are polled (default: 4). It has a minimum
  291. value of 1 to avoid hammering servers.
  292. .It Ic disable_notify_webhook
  293. Since version 2.78, users can set a webhook URL to receive notifications. Set this
  294. to true if you don't want your users to have this privilege.
  295. .It Ic favicon_url
  296. The URL to a favicon. If it's not set, the default one is used instead.
  297. .It Ic max_failing_days
  298. The maximum number of days an instance is considered down after continuous failed
  299. outgoing messages (default: 15). Anyway, whenever any incoming activity from a
  300. failed instance is detected, this counter is reset for it.
  301. .It Ic vkey
  302. Public vapid key. Used for notification on some client.
  303. .It Ic disable_emojireact
  304. If set to true, all EmojiReact support (for input and output) is disabled.
  305. .It Ic strip_exif
  306. If set to true, EXIF and other metadata will be stripped from uploaded images (jpg, png, webp, heic, avif, tiff, gif, bmp) and videos (mp4, m4v, mov, webm, mkv, avi). This requires the
  307. .Nm mogrify
  308. (from ImageMagick) and
  309. .Nm ffmpeg
  310. tools to be installed. If
  311. .Nm snac
  312. cannot find or execute these tools at startup, it will refuse to run.
  313. .Pp
  314. When enabled, registered users might pass arbitrary files to
  315. .Nm mogrify
  316. or
  317. .Nm ffmpeg .
  318. These commands are being executed outside the sandbox and have a huge
  319. attack surface. Exploits would be run as the
  320. .Nm
  321. system user. Reconsider enabling this on
  322. .Nm
  323. instances with unknown or untrusted users.
  324. .It Ic mogrify_path
  325. Overrides the default "mogrify" command name or path. Use this if the tool is not in the system PATH or has a different name.
  326. .It Ic ffmpeg_path
  327. Overrides the default "ffmpeg" command name or path. Use this if the tool is not in the system PATH or has a different name.
  328. .El
  329. .Pp
  330. You must restart the server to make effective these changes.
  331. .Pp
  332. If a file named
  333. .Pa greeting.html
  334. is present in the server base directory, it will be returned whenever
  335. the base URL of the server is requested. Fill it with whatever
  336. information about the instance you want to supply to people
  337. visiting the server, like sign up requirements, site policies
  338. and such. The special %userlist% mark in the file will cause
  339. the list of users in this instance to be inserted.
  340. .Pp
  341. Users can change a bit of information about themselves from the
  342. web interface. See
  343. .Xr snac 1
  344. for details. Further, every user can have a private CSS file in their
  345. .Pa static/style.css
  346. that will be served instead of the server-wide one.
  347. It's not modifiable from the web interface to avoid users
  348. shooting themselves in the foot by destroying everything.
  349. .Ss Custom Emojis
  350. From version 2.51, support for customized Emojis in posts is available
  351. (previously, they were hardcoded). Emojis are read from the
  352. .Pa emojis.json
  353. file in the instance base directory, as a JSON object of key / value
  354. pairs (if this file does not exist, it will be created with
  355. the predefined set). Each key in the object contains the text to be found (e.g.,
  356. the :-) for a smiling face), and its associated value, the text string that
  357. will replace it (in this example case, the HTML entity for the Unicode codepoint
  358. for the smiley or the Emoji itself as text).
  359. .Pp
  360. Emoji values can also be URLs to image files; in this case, they will not be
  361. substituted in the post content, but added to the 'tag' array as an ActivityPub
  362. standard 'Emoji' object (it's recommendable that the Emoji key be enclosed in
  363. colons for maximum compatibility with other ActivityPub implementations, like
  364. e.g. :happydoggo:). These images can be served from an external source or from the
  365. .Pa static
  366. directory of the instance admin.
  367. .Pp
  368. If you want to disable any Emoji substitution, change the file to contain
  369. just an empty JSON object ({}).
  370. .Ss SPAM Mitigation
  371. There have been some SPAM attacks on the Fediverse and, as too many
  372. instances and server implementations out there still allow automatic
  373. account creation, it will only get worse.
  374. .Nm
  375. includes some (not very strong) tools for trying to survive the SPAM
  376. flood that will eventually happen.
  377. .Pp
  378. The
  379. .Ic min_account_age
  380. field in the main configuration file allows setting a minimum age (in
  381. seconds) to consider too recently created accounts suspicious of being
  382. a potential source of SPAM. This is a naïve assumption, because spammers
  383. can create accounts, let them dormant for a while and then start to use
  384. them. Also, some ActivityPub implementations don't even bother to return
  385. a creation date for their accounts, so this is not very useful.
  386. .Pp
  387. From version 2.50, post content can be filtered out by regular expressions.
  388. These weapons of mass destruction can be written into the
  389. .Ic filter_reject.txt
  390. file in the server base directory, one per line; if this file exists,
  391. all posts' content will be matched (after being stripped of HTML tags)
  392. against these regexes, one by one, and any match will make the post to
  393. be rejected. Use lower case, the regex will be case insensitive by default.
  394. If you don't know about regular expressions, don't use this
  395. option (or learn about them inw some tutorial, there are gazillions of
  396. them out there), as you and your users may start missing posts. Also,
  397. given that every regular expression implementation supports a different
  398. set of features, consider reading the documentation about the one
  399. implemented in your system.
  400. .Ss ActivityPub Support
  401. These are the following activities and objects that
  402. .Nm
  403. supports:
  404. .Bl -tag -width tenletters
  405. .It Vt Follow
  406. Complete support, on input and output.
  407. .It Vt Undo
  408. For
  409. .Vt Follow ,
  410. .Vt Like
  411. and
  412. .Vt Announce
  413. objects, on input and output.
  414. .It Vt Create
  415. For
  416. .Vt Note ,
  417. .Vt Question ,
  418. .Vt Page ,
  419. .Vt Article ,
  420. .Vt Event
  421. and
  422. .Vt Video
  423. objects on input, and for
  424. .Vt Note
  425. and
  426. .Vt Question
  427. on output.
  428. .It Vt Accept
  429. For
  430. .Vt Follow
  431. objects, on input and output.
  432. .It Vt Like
  433. For
  434. .Vt Note
  435. objects, on input and output.
  436. .It Vt EmojiReact
  437. For
  438. .Vt Note
  439. objects, on input and output.
  440. .It Vt Announce
  441. For
  442. .Vt Note
  443. objects, on input and output.
  444. .It Vt Update
  445. For
  446. .Vt Note ,
  447. .Vt Question ,
  448. .Vt Page ,
  449. .Vt Article ,
  450. .Vt Event
  451. and
  452. .Vt Video
  453. objects on input, and for
  454. .Vt Note
  455. on output.
  456. .It Vt Delete
  457. Supported for
  458. .Vt Note
  459. and
  460. .Vt Tomsbtone
  461. objects on input, and for
  462. .Vt Note
  463. objects on output.
  464. .It Vt Move
  465. For actor-like objects, for input and output.
  466. .El
  467. .Pp
  468. The rest of activities and objects are dropped on input.
  469. .Pp
  470. There is partial support for
  471. .Vt OrderedCollection
  472. objects in the
  473. .Pa /outbox
  474. (with the last 20 entries of the local timeline shown). No pagination
  475. is supported. Intentionally, the
  476. .Pa /followers
  477. and
  478. .Pa /following
  479. paths return empty lists.
  480. .Ss Migrating from snac to Mastodon
  481. Since version 2.60, you can migrate your
  482. .Nm
  483. account to other ActivityPub instances. What is described here is the process to do it from
  484. .Nm
  485. to Mastodon; on other software implementations, it will surely be somewhat different. All
  486. the steps regarding your
  487. .Nm
  488. account must be done from the command line. For the sake of the example, let's
  489. say that you want to migrate from an account named @origin@snac.example.org to
  490. another one named @destination@mastodon.example.com and that both of them
  491. already exist. I've used this very informative page as a guideline:
  492. .Pp
  493. .Lk https://fedi.tips/transferring-your-mastodon-account-to-another-server/
  494. .Pp
  495. 1. On your
  496. .Nm
  497. server, first export your data to CSV by running:
  498. .Bd -literal -offset indent
  499. snac export_csv $SNAC_BASEDIR origin
  500. .Ed
  501. .Pp
  502. You'll find the following CSV files in the
  503. .Pa export/
  504. subdirectory inside the user directory:
  505. .Pa bookmarks.csv ,
  506. .Pa blocked_accounts.csv ,
  507. .Pa lists.csv , and
  508. .Pa following_accounts.csv .
  509. .Pp
  510. 2. In the web interface of your new Mastodon account, click on
  511. .Vt Preferences
  512. >
  513. .Vt Import and Export
  514. >
  515. .Vt Import
  516. and upload the CSV files one at a time. You must specify the type of
  517. file you are uploading.
  518. .Pp
  519. 3. Still in the web interface of your new Mastodon account, click on
  520. .Vt Preferences
  521. >
  522. .Vt Account
  523. >
  524. .Vt Moving From a Different Account ,
  525. then click on
  526. .Vt Create an account alias
  527. and follow the instructions. (When it asks you to
  528. write your old account’s handle, it needs to include the @ at the start
  529. as well as the @ in the middle; as of our example, @origin@snac.example.org).
  530. It seems this step is not performed immediately, you must wait an unspecified
  531. number of minutes for this to be effective.
  532. .Pp
  533. 4. Meanwhile, you must tell
  534. .Nm
  535. about your new account by creating an alias from your current one.
  536. So, on your
  537. .Nm
  538. server, run
  539. .Bd -literal -offset indent
  540. snac alias $SNAC_BASEDIR origin "@destination@mastodon.example.com"
  541. .Ed
  542. .Pp
  543. 5. Finally, you must order
  544. .Nm
  545. to start the migration process, that will consist in iterating all the
  546. people that follows your account and sending them a
  547. .Vt Move
  548. message, that acts as a suggestion to unfollow your old account
  549. and follow the new one. The command is
  550. .Bd -literal -offset indent
  551. snac migrate $SNAC_BASEDIR origin
  552. .Ed
  553. .Pp
  554. This process can be very long and unreliable; any destination server may be down,
  555. too busy, disconnected or gone. I recommend you to read the document I linked
  556. above to know about all the sorrows awaiting.
  557. .Pp
  558. Also, please take note that the
  559. .Nm
  560. account you migrated from is not disabled nor changed in any way, so can still
  561. use it as it no migration was done. This behaviour may or may not match what other
  562. ActivityPub implementations do.
  563. .Pp
  564. .Ss Migrating from Mastodon to snac
  565. Since version 2.61, you can migrate accounts on other ActivityPub instances to your
  566. .Nm
  567. one. What is described here is the process to do it from
  568. Mastodon; on other software implementations, it will surely be somewhat different. All
  569. the steps regarding your
  570. .Nm
  571. account must be done from the command line. For the sake of the example, let's
  572. say that you want to migrate from an account named @origin@mastodon.example.com to
  573. another one named @destination@snac.example.org and that both of them
  574. already exist. I've used this very informative page as a guideline:
  575. .Pp
  576. .Lk https://fedi.tips/transferring-your-mastodon-account-to-another-server/
  577. .Pp
  578. 1. On the web interface of your origin Mastodon account, click on
  579. .Vt Preferences
  580. >
  581. .Vt Import and Export
  582. >
  583. .Vt Export
  584. and download the CSV files under the "Follows", "Lists", "You Block" and "Bookmarks"
  585. labels. After being downloaded, you should find the following files on your download
  586. directory:
  587. .Pa bookmarks.csv ,
  588. .Pa blocked_accounts.csv ,
  589. .Pa lists.csv , and
  590. .Pa following_accounts.csv .
  591. .Pp
  592. 2. Copy all those files to the
  593. .Pa import/
  594. subdirectory of the user's directory inside the server base directory, and run
  595. .Bd -literal -offset indent
  596. snac import_csv $SNAC_BASEDIR destination
  597. .Ed
  598. .Pp
  599. This process may take some time because it depends on the availability / responsiveness
  600. of all the ActivityPub servers involved (webfinger, accounts, posts, etc.). Some errors
  601. may be transient and retried later. Also, if
  602. .Nm
  603. complains that it can't find any of these files, please check that they are really
  604. stored in the
  605. .Pa import/
  606. subdirectory and that their names match exactly. Some of them may be
  607. empty (for example, if you didn't create any list) and that's fine.
  608. .Pp
  609. 3. Again on your
  610. .Nm
  611. server, run
  612. .Bd -literal -offset indent
  613. snac alias $SNAC_BASEDIR destination "@origin@mastodon.example.com"
  614. .Ed
  615. .Pp
  616. Check that no errors were shown. If they do, the origin Mastodon server may be
  617. busy or down; try again later.
  618. .Pp
  619. 4. Move back to the web interface of the origin Mastodon account, go to
  620. .Vt Preferences
  621. >
  622. .Vt Account
  623. >
  624. .Vt Move To A Different Account ,
  625. and follow the instructions there. Set the handle of the new account to your
  626. .Nm
  627. one; as of our example, @destination@snac.example.org. This will start the migration
  628. process: it's the duty of your old Mastodon instance to send an automatic
  629. .Vt Move
  630. message to every one of your followers. Eventually, you will start receiving follow notifications to your
  631. .Nm
  632. account from all accounts that followed the Mastodon one. According to the great document
  633. I linked above, this process may or may not start immediately, and its success may depend
  634. heavily on how all the servers involved behave. Just cross your fingers and hope for the best.
  635. .Pp
  636. .Ss Instance blocking
  637. Full instances can be blocked. This operation must be done from
  638. the command-line tool. See
  639. .Xr snac 1 .
  640. .Pp
  641. .Ss Bad login throttling
  642. Since version 2.67, a simple logic to avoid brute force attacks against user passwords
  643. has been implemented: if, from a given IP address, the number of failed logins reaches
  644. a given threshold, further tries from that IP address are never successful until a timer
  645. expires. The maximum number of retries can be configured in the
  646. .Pa server.json
  647. file by setting the
  648. .Ic badlogin_retries
  649. variable, and the number of seconds the IP address unlock timer expires, in
  650. .Ic badlogin_expire .
  651. Please take note that, for this system to work, you must setup your web server proxy
  652. to pass the remote connection address in the
  653. .Ic X-Forwarded-For
  654. HTTP header (unless you use the FastCGI interface; if that's the case, you don't have
  655. to do anything).
  656. .Pp
  657. .Ss Subscribing to Fediverse Relays
  658. Since version 2.69, a
  659. .Nm
  660. instance can subscribe to LitePub (Pleroma-style) Fediverse Relays. Doing this improves
  661. visibility and allows following hashtags. To do this, you must create a special user named
  662. relay and, from it, follow the relay actor(s) like you do with regular actor URLs. This
  663. special user will start receiving boosts from the relay server of posts from other instances
  664. also following it. If any other user of the same
  665. .Nm
  666. instance follows any of the hashtags included in these boosted posts coming from the relay,
  667. they will be received as if they were for them.
  668. .Pp
  669. Example:
  670. .Bd -literal -offset indent
  671. snac adduser $SNAC_BASEDIR relay # only needed once
  672. snac follow $SNAC_BASEDIR relay https://relay.example.com/actor
  673. .Ed
  674. .Pp
  675. Users on your instance do NOT need to follow the local relay user to benefit from following
  676. hashtags.
  677. .Pp
  678. Please take note that subscribing to relays can increase the traffic towards your instance
  679. significantly. In any case, lowering the "Maximum days to keep posts" value for the relay
  680. special user is recommended (e.g. setting to just 1 day).
  681. .Ss Web interface language
  682. Since version 2.73, the web UI can be localized via simple .po files (they are directly
  683. parsed, no support for gettext is needed).
  684. .Pp
  685. No language file is installed by default; the administrator must copy any desired .po files
  686. to the
  687. .Pa lang/
  688. subdirectory in the base directory. Once the server is restarted, users can select the
  689. new language from the user settings. The
  690. .Nm
  691. source distribution may include .po files in the
  692. .Pa po/
  693. subdirectory. You don't need to copy the English language one, as it's the default.
  694. .Pp
  695. To create new language files, create a copy of
  696. .Pa po/en.po ,
  697. rename it to a reasonable value like
  698. .Pa pl.po
  699. or
  700. .Pa pt_BR.po ,
  701. change the translator in the header to yourself and fill the msgstr strings with your
  702. translation. If you have any doubt on how to modify .po files, there are many tutorials
  703. out there. If you want your language file to be included in the standard
  704. .Nm
  705. distribution, please send me a link to it via the Fediverse to @grunfink@comam.es
  706. or make a PR via the Git repository.
  707. .Ss Number of open files on OpenBSD and login classes
  708. Being a file intensive application, even a small
  709. .Nm
  710. instance might open lots of files, especially when forwarding a new post to
  711. other instances.
  712. .Pp
  713. OpenBSD's daemon login class comes with a very low
  714. .Pa openfiles
  715. value, usually restricting the amount of open files to 128 (cur), 1024 (max).
  716. This can result in
  717. .Nm
  718. to stop working due to too many open files.
  719. .Pp
  720. To continue operation, a new
  721. .Pa snac
  722. login class can be created. Please consult
  723. .Xr login.conf 5
  724. and afterwards create a new login class as follows.
  725. .Bd -literal -offset indent
  726. snac:\\
  727. :openfiles=4096:\\
  728. :tc=daemon:
  729. .Ed
  730. .Pp
  731. After rebuilding the
  732. .Pa /etc/login.conf.db ,
  733. ensure that your snac user's login class is set to
  734. .Pa snac :
  735. .Bd -literal -offset indent
  736. # cap_mkdb /etc/login.conf
  737. # usermod -L snac SNACUSER
  738. .Ed
  739. .Pp
  740. One restart later, the daemon should run with increased
  741. .Pa openfiles .
  742. .Sh ENVIRONMENT
  743. .Bl -tag -width Ds
  744. .It Ev DEBUG
  745. Overrides the debugging level from the server 'dbglevel' configuration
  746. variable. Set it to an integer value. The higher, the deeper in meaningless
  747. verbiage you'll find yourself into.
  748. .El
  749. .Sh EXAMPLES
  750. You want to install the
  751. .Nm
  752. Fediverse daemon in the host example.com, that is correctly configured
  753. with a valid TLS certificate and running the nginx httpd server.
  754. The service will be installed under the
  755. .Pa fedi
  756. location. Two users, walter and jessie, will be hosted in the system.
  757. Their Fediverse presence addresses will be
  758. .Lk https://example.com/fedi/walter
  759. and
  760. .Lk https://example.com/fedi/jesse ,
  761. respectively. They will be known
  762. in the Fediverse as @walter@example.com and @jesse@example.com. The
  763. .Nm
  764. daemon will run as the user snacusr in the system and listen to the
  765. localhost:8001 network socket. All data will be stored in the
  766. .Pa /home/snacusr/fedidata
  767. directory.
  768. .Pp
  769. Log into the system as snacusr and execute:
  770. .Bd -literal -offset indent
  771. snac init /home/snacusr/fedidata
  772. .Ed
  773. .Pp
  774. Answer "example.com" to the host name question, "/fedi" to the path
  775. prefix question, "localhost" to the address and "8001" to the port.
  776. .Pp
  777. Create the users
  778. .Bd -literal -offset indent
  779. snac adduser /home/snacusr/fedidata walter
  780. snac adduser /home/snacusr/fedidata jesse
  781. .Ed
  782. .Pp
  783. Answer the questions with reasonable values.
  784. .Pp
  785. Execute the server:
  786. .Bd -literal -offset indent
  787. snac httpd /home/snacusr/fedidata
  788. .Ed
  789. .Pp
  790. Edit the nginx configuration and add the following snippet to the
  791. example.com server section:
  792. .Bd -literal -offset indent
  793. # nginx configuration example
  794. # main web access point
  795. location /fedi {
  796. proxy_pass http://localhost:8001;
  797. proxy_set_header Host $http_host;
  798. proxy_set_header X-Forwarded-For $remote_addr;
  799. }
  800. # webfinger
  801. location /.well-known/webfinger {
  802. proxy_pass http://localhost:8001;
  803. proxy_set_header Host $http_host;
  804. proxy_set_header X-Forwarded-For $remote_addr;
  805. }
  806. # Mastodon API (entry points)
  807. location /api/v1/ {
  808. proxy_pass http://localhost:8001;
  809. proxy_set_header Host $http_host;
  810. proxy_set_header X-Forwarded-For $remote_addr;
  811. }
  812. location /api/v2/ {
  813. proxy_pass http://localhost:8001;
  814. proxy_set_header Host $http_host;
  815. proxy_set_header X-Forwarded-For $remote_addr;
  816. }
  817. # Mastodon API (OAuth support)
  818. location /oauth {
  819. proxy_pass http://localhost:8001;
  820. proxy_set_header Host $http_host;
  821. proxy_set_header X-Forwarded-For $remote_addr;
  822. }
  823. # optional
  824. location /.well-known/nodeinfo {
  825. proxy_pass http://localhost:8001;
  826. proxy_set_header Host $http_host;
  827. proxy_set_header X-Forwarded-For $remote_addr;
  828. }
  829. # optional (needed by some Mastodon API clients)
  830. location /.well-known/host-meta {
  831. proxy_pass http://localhost:8001;
  832. proxy_set_header Host $http_host;
  833. proxy_set_header X-Forwarded-For $remote_addr;
  834. }
  835. # optional (Mastodon-like link share entrypoint)
  836. location /share {
  837. proxy_pass http://localhost:8001;
  838. proxy_set_header Host $http_host;
  839. proxy_set_header X-Forwarded-For $remote_addr;
  840. }
  841. # optional (Mastodon-like "authorize interaction" entrypoint)
  842. location /authorize_interaction {
  843. proxy_pass http://localhost:8001;
  844. proxy_set_header Host $http_host;
  845. proxy_set_header X-Forwarded-For $remote_addr;
  846. }
  847. .Ed
  848. .Pp
  849. Restart the nginx daemon and connect to
  850. .Lk https://example.com/fedi/walter .
  851. The empty, default screen will be shown. Enter the admin section with the
  852. credentials defined for this user. Search people, start following
  853. them, engage in arid discussions and generally enjoy the frustrating
  854. experience of Social Media.
  855. .Pp
  856. This is an example of a similar configuration for the Apache2 web server:
  857. .Bd -literal -offset indent
  858. # apache2 configuration example
  859. ProxyPreserveHost On
  860. # Main web access point
  861. <Location /fedi>
  862. ProxyPass http://127.0.0.1:8001/social
  863. </Location>
  864. # WebFinger
  865. <Location /.well-known/webfinger>
  866. ProxyPass http://127.0.0.1:8001/.well-known/webfinger
  867. </Location>
  868. # Mastodon API (entry points)
  869. <Location /api/v1/>
  870. ProxyPass http://127.0.0.1:8001/api/v1/
  871. </Location>
  872. <Location /api/v2/>
  873. ProxyPass http://127.0.0.1:8001/api/v2/
  874. </Location>
  875. # Mastodon API (OAuth support)
  876. <Location /oauth>
  877. ProxyPass http://127.0.0.1:8001/oauth
  878. </Location>
  879. # NodeInfo (optional)
  880. <Location /.well-known/nodeinfo>
  881. ProxyPass http://127.0.0.1:8001/.well-known/nodeinfo
  882. </Location>
  883. # host-meta (optional, needed for some Mastodon API clients)
  884. <Location /.well-known/host-meta>
  885. ProxyPass http://127.0.0.1:8001/.well-known/host-meta
  886. </Location>
  887. # optional (Mastodon-like link share entrypoint)
  888. <Location /share>
  889. ProxyPass http://127.0.0.1:8001/share
  890. </Location>
  891. # optional (Mastodon-like "authorize interaction" entrypoint)
  892. <Location /authorize_interaction>
  893. ProxyPass http://127.0.0.1:8001/share
  894. </Location>
  895. .Ed
  896. .Pp
  897. Since version 2.43,
  898. .Nm
  899. supports communicating from / to the front end http server using the FastCGI
  900. protocol. There is no special advantage in using this, only that some servers
  901. allow for simpler configuration. For example, in the case of nginx, you can
  902. replace the two 'proxy_pass' and 'proxy_set_header' lines in the example
  903. above with just
  904. .Bd -literal -offset indent
  905. fastcgi_pass localhost:8001;
  906. .Ed
  907. .Pp
  908. The only thing to change on
  909. .Nm
  910. is to the set 'fastcgi' value to true in
  911. .Pa server.json .
  912. .Pp
  913. Further, using the FastCGI interface allows a much simpler configuration
  914. under OpenBSD's native httpd, given that it's natively implemented there
  915. and you no longer need to configure the complicated relayd server. This is
  916. an example:
  917. .Bd -literal -offset indent
  918. # OpenBSD httpd configuration example
  919. # other server configuration
  920. [...]
  921. location "/fedi/*" {
  922. fastcgi socket tcp "127.0.0.1" 8001
  923. }
  924. location "/.well-known/webfinger" {
  925. fastcgi socket tcp "127.0.0.1" 8001
  926. }
  927. location "/oauth/*" {
  928. fastcgi socket tcp "127.0.0.1" 8001
  929. }
  930. location "/api/v1/*" {
  931. fastcgi socket tcp "127.0.0.1" 8001
  932. }
  933. location "/api/v2/*" {
  934. fastcgi socket tcp "127.0.0.1" 8001
  935. }
  936. location "/.well-known/nodeinfo" {
  937. fastcgi socket tcp "127.0.0.1" 8001
  938. }
  939. location "/.well-known/host-meta" {
  940. fastcgi socket tcp "127.0.0.1" 8001
  941. }
  942. location "/share" {
  943. fastcgi socket tcp "127.0.0.1" 8001
  944. }
  945. location "/authorize_interaction" {
  946. fastcgi socket tcp "127.0.0.1" 8001
  947. }
  948. .Ed
  949. .Sh SEE ALSO
  950. .Xr snac 1 ,
  951. .Xr snac 5
  952. .Sh AUTHORS
  953. .An grunfink Lk https://comam.es/snac/grunfink @grunfink@comam.es
  954. .Sh LICENSE
  955. See the LICENSE file for details.
  956. .Sh CAVEATS
  957. JSON files are fragile when modified by hand. Take care.