stdiscosrv.1 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .TH "STDISCOSRV" "1" "May 17, 2018" "v0.14" "Syncthing"
  4. .SH NAME
  5. stdiscosrv \- Syncthing Discovery Server
  6. .
  7. .nr rst2man-indent-level 0
  8. .
  9. .de1 rstReportMargin
  10. \\$1 \\n[an-margin]
  11. level \\n[rst2man-indent-level]
  12. level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
  13. -
  14. \\n[rst2man-indent0]
  15. \\n[rst2man-indent1]
  16. \\n[rst2man-indent2]
  17. ..
  18. .de1 INDENT
  19. .\" .rstReportMargin pre:
  20. . RS \\$1
  21. . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
  22. . nr rst2man-indent-level +1
  23. .\" .rstReportMargin post:
  24. ..
  25. .de UNINDENT
  26. . RE
  27. .\" indent \\n[an-margin]
  28. .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
  29. .nr rst2man-indent-level -1
  30. .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
  31. .in \\n[rst2man-indent\\n[rst2man-indent-level]]u
  32. ..
  33. .SH SYNOPSIS
  34. .INDENT 0.0
  35. .INDENT 3.5
  36. .sp
  37. .nf
  38. .ft C
  39. stdiscosrv [\-cert=<file>] [\-db\-dir=<string>] [\-debug] [\-http] [\-key=<string>]
  40. [\-listen=<address>] [\-metrics\-listen=<address>]
  41. [\-replicate=<peers>] [\-replication\-listen=<address>]
  42. .ft P
  43. .fi
  44. .UNINDENT
  45. .UNINDENT
  46. .SH DESCRIPTION
  47. .sp
  48. Syncthing relies on a discovery server to find peers on the internet. Anyone
  49. can run a discovery server and point Syncthing installations to it. The
  50. Syncthing project also maintains a global cluster for public use.
  51. .SH OPTIONS
  52. .INDENT 0.0
  53. .TP
  54. .B \-cert=<file>
  55. Certificate file (default “./cert.pem”).
  56. .UNINDENT
  57. .INDENT 0.0
  58. .TP
  59. .B \-db\-dir=<string>
  60. Database directory, where data is stored (default “./discovery.db”).
  61. .UNINDENT
  62. .INDENT 0.0
  63. .TP
  64. .B \-debug
  65. Enable debug output.
  66. .UNINDENT
  67. .INDENT 0.0
  68. .TP
  69. .B \-http
  70. Listen on HTTP (behind an HTTPS proxy).
  71. .UNINDENT
  72. .INDENT 0.0
  73. .TP
  74. .B \-key=<file>
  75. Key file (default “./key.pem”).
  76. .UNINDENT
  77. .INDENT 0.0
  78. .TP
  79. .B \-listen=<address>
  80. Listen address (default “:8443”).
  81. .UNINDENT
  82. .INDENT 0.0
  83. .TP
  84. .B \-metrics\-listen=<address>
  85. Prometheus compatible metrics endpoint listen address (default disabled).
  86. .UNINDENT
  87. .INDENT 0.0
  88. .TP
  89. .B \-replicate=<peers>
  90. Replication peers, \fI\%id@address\fP <\fBid@address\fP>, comma separated
  91. .UNINDENT
  92. .INDENT 0.0
  93. .TP
  94. .B \-replication\-listen=<address>
  95. Listen address for incoming replication connections (default “:19200”).
  96. .UNINDENT
  97. .SH POINTING SYNCTHING AT YOUR DISCOVERY SERVER
  98. .sp
  99. By default, Syncthing uses a number of global discovery servers, signified by
  100. the entry \fBdefault\fP in the list of discovery servers. To make Syncthing use
  101. your own instance of stdiscosrv, open up Syncthing’s web GUI. Go to settings,
  102. Global Discovery Server and add stdiscosrv’s host address to the comma\-separated
  103. list, e.g. \fBhttps://disco.example.com:8443/\fP\&. Note that stdiscosrv uses port
  104. 8443 by default. For stdiscosrv to be available over the internet with a dynamic
  105. IP address, you will need a dynamic DNS service.
  106. .sp
  107. If you wish to use \fIonly\fP your own discovery server, remove the \fBdefault\fP
  108. entry from the list.
  109. .SH SETTING UP
  110. .SS Description
  111. .sp
  112. This guide assumes that you have already set up Syncthing. If you
  113. haven’t yet, head over to getting\-started first.
  114. .SS Installing
  115. .sp
  116. Go to \fI\%releases\fP <\fBhttps://github.com/syncthing/discosrv/releases\fP> and
  117. download the file appropriate for your operating system. Unpacking it will
  118. yield a binary called \fBstdiscosrv\fP (or \fBstdiscosrv.exe\fP on Windows).
  119. Start this in whatever way you are most comfortable with; double clicking
  120. should work in any graphical environment. At first start, stdiscosrv will
  121. generate certificate files and database in the current directory unless
  122. given flags to the contrary.
  123. .SS Configuring
  124. .sp
  125. \fBNOTE:\fP
  126. .INDENT 0.0
  127. .INDENT 3.5
  128. If you are running an instance of Syncthing on the discovery server,
  129. you must either add that instance to other devices using a static
  130. address or bind the discovery server and Syncthing instances to
  131. different IP addresses.
  132. .UNINDENT
  133. .UNINDENT
  134. .SS Certificates
  135. .sp
  136. The discovery server provides service over HTTPS. To ensure secure connections
  137. from clients there are three options:
  138. .INDENT 0.0
  139. .IP \(bu 2
  140. Use a CA\-signed certificate pair for the domain name you will use for the
  141. discovery server. This is like any other HTTPS website; clients will
  142. authenticate the server based on its certificate and domain name.
  143. .IP \(bu 2
  144. Use any certificate pair and let clients authenticate the server based on
  145. its “device ID” (similar to Syncthing\-to\-Syncthing authentication). This
  146. option can be used with the certificate automatically generated by the
  147. discovery server.
  148. .IP \(bu 2
  149. Pass the \fB\-http\fP flag if the discovery server is behind an SSL\-secured
  150. reverse proxy. See below for configuration.
  151. .UNINDENT
  152. .sp
  153. For the first two options, the discovery server must be given the paths to
  154. the certificate and key at startup. This isn’t necessary with the \fBhttp\fP flag:
  155. .INDENT 0.0
  156. .INDENT 3.5
  157. .sp
  158. .nf
  159. .ft C
  160. $ stdiscosrv \-cert=/path/to/cert.pem \-key=/path/to/key.pem
  161. Server device ID is 7DDRT7J\-UICR4PM\-PBIZYL3\-MZOJ7X7\-EX56JP6\-IK6HHMW\-S7EK32W\-G3EUPQA
  162. .ft P
  163. .fi
  164. .UNINDENT
  165. .UNINDENT
  166. .sp
  167. The discovery server prints its device ID at startup. In case you are using
  168. a non CA signed certificate, this device ID (fingerprint) must be given to
  169. the clients in the discovery server URL:
  170. .INDENT 0.0
  171. .INDENT 3.5
  172. .sp
  173. .nf
  174. .ft C
  175. https://disco.example.com:8443/?id=7DDRT7J\-UICR4PM\-PBIZYL3\-MZOJ7X7\-EX56JP6\-IK6HHMW\-S7EK32W\-G3EUPQA
  176. .ft P
  177. .fi
  178. .UNINDENT
  179. .UNINDENT
  180. .sp
  181. Otherwise, the URL will be:
  182. .INDENT 0.0
  183. .INDENT 3.5
  184. .sp
  185. .nf
  186. .ft C
  187. https://disco.example.com:8443/
  188. .ft P
  189. .fi
  190. .UNINDENT
  191. .UNINDENT
  192. .SS Replication
  193. .sp
  194. The discovery server can be deployed in a redundant, load sharing fashion.
  195. In this mode announcements are replicated from the server that receives them
  196. to other peer servers and queries can be answered equally by all servers.
  197. .sp
  198. Replication connections are encrypted and authenticated using TLS. The
  199. certificate is selected by the \fB\-cert\fP and \fB\-key\fP options and is thus
  200. shared with the main discovery API. If the \fB\-http\fP mode is used the
  201. certificate is not used for client requests but only for replication
  202. connections.
  203. .sp
  204. Authentication of replication connections is done using \fI\%Syncthing\-style
  205. device IDs\fP <\fBhttps://docs.syncthing.net/dev/device-ids.html#id1\fP> only \- CA
  206. verification is not available. The device IDs in question are those printed
  207. by the discovery server on startup.
  208. .sp
  209. Replication connections are unidirectional \- announcements are replication
  210. from the \fBsender\fP to a \fBlistener\fP\&. In order to have a bidirectional
  211. replication relationship between two servers both need to be configured as
  212. sender and listener.
  213. .sp
  214. As an example, lets assume two discovery servers:
  215. .INDENT 0.0
  216. .IP \(bu 2
  217. Server one is on 192.0.2.20 and has certificate ID I6K…H76
  218. .IP \(bu 2
  219. Server two is on 192.0.2.55 and has certificate ID MRI…7OK
  220. .UNINDENT
  221. .sp
  222. In order for both to replicate to the other and thus form a redundant pair,
  223. use the following commands.
  224. .sp
  225. On server one:
  226. .INDENT 0.0
  227. .INDENT 3.5
  228. .sp
  229. .nf
  230. .ft C
  231. $ stdiscosrv \[email protected]:19200 <other options>
  232. .ft P
  233. .fi
  234. .UNINDENT
  235. .UNINDENT
  236. .sp
  237. On server two:
  238. .INDENT 0.0
  239. .INDENT 3.5
  240. .sp
  241. .nf
  242. .ft C
  243. $ stdiscosrv \[email protected]:19200 <other options>
  244. .ft P
  245. .fi
  246. .UNINDENT
  247. .UNINDENT
  248. .sp
  249. The \fB\-replicate\fP directive sets which remote device IDs are expected and
  250. allowed for both outgoing (sending) and incoming (listening) connections,
  251. and which addresses to use when connecting out to those peers. Both IP and
  252. port must be specified in peer addresses.
  253. .sp
  254. It is possible to only allow incoming connections from a peer without
  255. establishing an outgoing replication connection. To do so, give only the
  256. device ID without “@ip:port” address:
  257. .INDENT 0.0
  258. .INDENT 3.5
  259. .sp
  260. .nf
  261. .ft C
  262. $ stdiscosrv \-replicate=I6K...H76 <other options>
  263. .ft P
  264. .fi
  265. .UNINDENT
  266. .UNINDENT
  267. .sp
  268. Discosrv will listen on the replication port only when \fB\-replicate\fP is
  269. given. The default replication listen address is “:19200”.
  270. .sp
  271. To achieve load balancing over two mutually replicating discovery server
  272. instances, add multiple A / AAAA DNS records for a given name and point
  273. Syncthing towards this name. The same certificate must be used on both
  274. discovery servers.
  275. .SS Reverse Proxy Setup
  276. .sp
  277. The discovery server can be run behind an SSL\-secured reverse proxy. This
  278. allows:
  279. .INDENT 0.0
  280. .IP \(bu 2
  281. Use of a subdomain name without requiring a port number added to the URL
  282. .IP \(bu 2
  283. Sharing an SSL certificate with multiple services on the same server
  284. .UNINDENT
  285. .SS Requirements
  286. .INDENT 0.0
  287. .IP \(bu 2
  288. Run the discovery server using the \-http flag \fBstdiscosrv \-http\fP\&.
  289. .IP \(bu 2
  290. SSL certificate/key configured for the reverse proxy
  291. .IP \(bu 2
  292. The “X\-Forwarded\-For” http header must be passed through with the client’s
  293. real IP address
  294. .IP \(bu 2
  295. The “X\-SSL\-Cert” must be passed through with the PEM\-encoded client SSL
  296. certificate
  297. .IP \(bu 2
  298. The proxy must request the client SSL certificate but not require it to be
  299. signed by a trusted CA.
  300. .UNINDENT
  301. .SS Nginx
  302. .sp
  303. These three lines in the configuration take care of the last three requirements
  304. listed above:
  305. .INDENT 0.0
  306. .INDENT 3.5
  307. .sp
  308. .nf
  309. .ft C
  310. proxy_set_header X\-Forwarded\-For $proxy_add_x_forwarded_for;
  311. proxy_set_header X\-SSL\-Cert $ssl_client_cert;
  312. ssl_verify_client optional_no_ca;
  313. .ft P
  314. .fi
  315. .UNINDENT
  316. .UNINDENT
  317. .sp
  318. The following is a complete example Nginx configuration file. With this setup,
  319. clients can use \fI\%https://discovery.example.com\fP as the discovery server URL in
  320. the Syncthing settings.
  321. .INDENT 0.0
  322. .INDENT 3.5
  323. .sp
  324. .nf
  325. .ft C
  326. # HTTP 1.1 support
  327. proxy_http_version 1.1;
  328. proxy_buffering off;
  329. proxy_set_header Host $http_host;
  330. proxy_set_header Upgrade $http_upgrade;
  331. proxy_set_header Connection $proxy_connection;
  332. proxy_set_header X\-Real\-IP $remote_addr;
  333. proxy_set_header X\-Forwarded\-For $proxy_add_x_forwarded_for;
  334. proxy_set_header X\-Forwarded\-Proto $proxy_x_forwarded_proto;
  335. proxy_set_header X\-SSL\-Cert $ssl_client_cert;
  336. upstream discovery.example.com {
  337. # Local IP address:port for discovery server
  338. server 192.0.2.1:8443;
  339. }
  340. server {
  341. server_name discovery.example.com;
  342. listen 80;
  343. access_log /var/log/nginx/access.log vhost;
  344. return 301 https://$host$request_uri;
  345. }
  346. server {
  347. server_name discovery.example.com;
  348. listen 443 ssl http2;
  349. access_log /var/log/nginx/access.log vhost;
  350. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  351. ssl_ciphers ECDHE\-RSA\-AES128\-GCM\-SHA256:ECDHE\-ECDSA\-AES128\-GCM\-SHA256:ECDHE\-RSA\-AES256\-GCM\-SHA384:ECDHE\-ECDSA\-AES256\-GCM\-SHA384: DHE\-RSA\-AES128\-GCM\-SHA256:DHE\-DSS\-AES128\-GCM\-SHA256:kEDH+AESGCM:ECDHE\-RSA\-AES128\-SHA256:ECDHE\-ECDSA\-AES128\-SHA256:ECDHE\-RSA\-AES128\-SHA:E CDHE\-ECDSA\-AES128\-SHA:ECDHE\-RSA\-AES256\-SHA384:ECDHE\-ECDSA\-AES256\-SHA384:ECDHE\-RSA\-AES256\-SHA:ECDHE\-ECDSA\-AES256\-SHA:DHE\-RSA\-AES128\-SHA25 6:DHE\-RSA\-AES128\-SHA:DHE\-DSS\-AES128\-SHA256:DHE\-RSA\-AES256\-SHA256:DHE\-DSS\-AES256\-SHA:DHE\-RSA\-AES256\-SHA:AES128\-GCM\-SHA256:AES256\-GCM\-SHA3 84:AES128\-SHA256:AES256\-SHA256:AES128\-SHA:AES256\-SHA:AES:CAMELLIA:DES\-CBC3\-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH\-DSS \-DES\-CBC3\-SHA:!EDH\-RSA\-DES\-CBC3\-SHA:!KRB5\-DES\-CBC3\-SHA;
  352. ssl_prefer_server_ciphers on;
  353. ssl_session_timeout 5m;
  354. ssl_session_cache shared:SSL:50m;
  355. ssl_certificate /etc/nginx/certs/discovery.example.com.crt;
  356. ssl_certificate_key /etc/nginx/certs/discovery.example.com.key;
  357. ssl_dhparam /etc/nginx/certs/discovery.example.com.dhparam.pem;
  358. add_header Strict\-Transport\-Security "max\-age=31536000";
  359. ssl_verify_client optional_no_ca;
  360. location / {
  361. proxy_pass http://discovery.example.com;
  362. }
  363. }
  364. .ft P
  365. .fi
  366. .UNINDENT
  367. .UNINDENT
  368. .sp
  369. An example of automating the SSL certificates and reverse\-proxying the Discovery
  370. Server and Syncthing using Nginx, \fI\%Let’s Encrypt\fP <\fBhttps://letsencrypt.org/\fP> and Docker can be found \fI\%here\fP <\fBhttps://forum.syncthing.net/t/docker-syncthing-and-syncthing-discovery-behind-nginx-reverse-proxy-with-lets-encrypt/6880\fP>\&.
  371. .SH SEE ALSO
  372. .sp
  373. \fBsyncthing\-networking(7)\fP, \fBsyncthing\-faq(7)\fP
  374. .SH AUTHOR
  375. The Syncthing Authors
  376. .SH COPYRIGHT
  377. 2014-2018, The Syncthing Authors
  378. .\" Generated by docutils manpage writer.
  379. .