snac.8 29 KB

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