stdiscosrv.1 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. .\" Man page generated from reStructuredText.
  2. .
  3. .TH "STDISCOSRV" "1" "March 31, 2017" "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\-backend=<string>] [\-db\-dsn=<string>] [\-debug] [\-http] [\-key=<string>]
  40. [\-limit\-avg=<int>] [\-limit\-burst=<int>] [\-limit\-cache=<int>] [\-listen=<address>]
  41. [\-stats\-file=<file>]
  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.
  50. .SH OPTIONS
  51. .INDENT 0.0
  52. .TP
  53. .B \-cert=<file>
  54. Certificate file (default "cert.pem").
  55. .UNINDENT
  56. .INDENT 0.0
  57. .TP
  58. .B \-db\-backend=<string>
  59. Database backend to use (default "ql").
  60. .UNINDENT
  61. .INDENT 0.0
  62. .TP
  63. .B \-db\-dsn=<string>
  64. Database DSN (default "memory://stdiscosrv").
  65. .UNINDENT
  66. .INDENT 0.0
  67. .TP
  68. .B \-debug
  69. Enable debug output.
  70. .UNINDENT
  71. .INDENT 0.0
  72. .TP
  73. .B \-http
  74. Listen on HTTP (behind an HTTPS proxy).
  75. .UNINDENT
  76. .INDENT 0.0
  77. .TP
  78. .B \-key=<file>
  79. Key file (default "key.pem").
  80. .UNINDENT
  81. .INDENT 0.0
  82. .TP
  83. .B \-limit\-avg=<int>
  84. Allowed average package rate, per 10 s (default 5).
  85. .UNINDENT
  86. .INDENT 0.0
  87. .TP
  88. .B \-limit\-burst=<int>
  89. Allowed burst size, packets (default 20).
  90. .UNINDENT
  91. .INDENT 0.0
  92. .TP
  93. .B \-limit\-cache=<int>
  94. Limiter cache entries (default 10240).
  95. .UNINDENT
  96. .INDENT 0.0
  97. .TP
  98. .B \-listen=<address>
  99. Listen address (default ":8443").
  100. .UNINDENT
  101. .INDENT 0.0
  102. .TP
  103. .B \-stats\-file=<file>
  104. File to write periodic operation stats to.
  105. .UNINDENT
  106. .SH POINTING SYNCTHING AT YOUR DISCOVERY SERVER
  107. .sp
  108. By default, Syncthing uses a number of global discovery servers, signified by
  109. the entry \fBdefault\fP in the list of discovery servers. To make Syncthing use
  110. your own instance of stdiscosrv, open up Syncthing\(aqs web GUI. Go to settings,
  111. Global Discovery Server and add stdiscosrv\(aqs host address to the comma\-separated
  112. list, e.g. \fBhttps://disco.example.com:8443/v2/\fP\&. Note that stdiscosrv uses port
  113. 8443 by default. For stdiscosrv to be available over the internet with a dynamic
  114. IP address, you will need a dynamic DNS service.
  115. .sp
  116. If you wish to use \fIonly\fP your own discovery server, remove the \fBdefault\fP
  117. entry from the list.
  118. .SH SETTING UP
  119. .SS Description
  120. .sp
  121. This guide assumes that you have already set up Syncthing. If you
  122. haven\(aqt yet, head over to getting\-started first.
  123. .SS Installing
  124. .sp
  125. Go to \fI\%releases\fP <\fBhttps://build.syncthing.net/job/stdiscosrv\fP> and
  126. download the file appropriate for your operating system. Unpacking it will
  127. yield a binary called \fBstdiscosrv\fP (or \fBstdiscosrv.exe\fP on Windows). Start
  128. this in whatever way you are most comfortable with; double clicking should
  129. work in any graphical environment. At first start, stdiscosrv will generate the
  130. directory \fB/var/stdiscosrv\fP (\fBX:\evar\estdiscosrv\fP on Windows, where X is the
  131. partition \fBstdiscosrv.exe\fP is executed from) with configuration. If the user
  132. running \fBstdiscosrv\fP doesn\(aqt have permission to do so, create the directory
  133. and set the owner appropriately or use the command line switches (see below)
  134. to select a different location.
  135. .SS Configuring
  136. .sp
  137. \fBNOTE:\fP
  138. .INDENT 0.0
  139. .INDENT 3.5
  140. If you are running an instance of Syncthing on the discovery server,
  141. you must either add that instance to other devices using a static
  142. address or bind the discovery server and Syncthing instances to
  143. different IP addresses.
  144. .UNINDENT
  145. .UNINDENT
  146. .SS Certificates
  147. .sp
  148. The discovery server provides service over HTTPS. To ensure secure connections
  149. from clients there are three options:
  150. .INDENT 0.0
  151. .IP \(bu 2
  152. Use a CA\-signed certificate pair for the domain name you will use for the
  153. discovery server. This is like any other HTTPS website; clients will
  154. authenticate the server based on it\(aqs certificate and domain name.
  155. .IP \(bu 2
  156. Use any certificate pair and let clients authenticate the server based on
  157. it\(aqs "device ID" (similar to Syncthing\-to\-Syncthing authentication). In
  158. this case, using \fBsyncthing \-generate\fP is a good option to create a
  159. certificate pair.
  160. .IP \(bu 2
  161. Pass the \fB\-http\fP flag if the discovery server is behind an SSL\-secured
  162. reverse proxy. See below for configuration.
  163. .UNINDENT
  164. .sp
  165. For the first two options, the discovery server must be given the paths to
  166. the certificate and key at startup. This isn\(aqt necessary with the \fBhttp\fP flag:
  167. .INDENT 0.0
  168. .INDENT 3.5
  169. .sp
  170. .nf
  171. .ft C
  172. $ stdiscosrv \-cert /path/to/cert.pem \-key /path/to/key.pem
  173. Server device ID is 7DDRT7J\-UICR4PM\-PBIZYL3\-MZOJ7X7\-EX56JP6\-IK6HHMW\-S7EK32W\-G3EUPQA
  174. .ft P
  175. .fi
  176. .UNINDENT
  177. .UNINDENT
  178. .sp
  179. The discovery server prints it\(aqs device ID at startup. In the case where you
  180. are using a non CA signed certificate, this device ID (fingerprint) must be
  181. given to the clients in the discovery server URL:
  182. .INDENT 0.0
  183. .INDENT 3.5
  184. .sp
  185. .nf
  186. .ft C
  187. https://disco.example.com:8443/v2/?id=7DDRT7J\-UICR4PM\-PBIZYL3\-MZOJ7X7\-EX56JP6\-IK6HHMW\-S7EK32W\-G3EUPQA
  188. .ft P
  189. .fi
  190. .UNINDENT
  191. .UNINDENT
  192. .sp
  193. Otherwise, the URL (note the trailing slash after the \fBv2\fP) will be:
  194. .INDENT 0.0
  195. .INDENT 3.5
  196. .sp
  197. .nf
  198. .ft C
  199. https://disco.example.com:8443/v2/
  200. .ft P
  201. .fi
  202. .UNINDENT
  203. .UNINDENT
  204. .SS Reverse Proxy Setup
  205. .sp
  206. The discovery server can be run behind an SSL\-secured reverse proxy. This
  207. allows:
  208. .INDENT 0.0
  209. .IP \(bu 2
  210. Use of a subdomain name without requiring a port number added to the URL
  211. .IP \(bu 2
  212. Sharing an SSL certificate with multiple services on the same server
  213. .UNINDENT
  214. .SS Requirements
  215. .INDENT 0.0
  216. .IP \(bu 2
  217. Run the discovery server using the \-http flag \fBstdiscosrv \-http\fP\&.
  218. .IP \(bu 2
  219. SSL certificate/key configured for the reverse proxy
  220. .IP \(bu 2
  221. The "X\-Forwarded\-For" http header must be passed through with the client\(aqs
  222. real IP address
  223. .IP \(bu 2
  224. The "X\-SSL\-Cert" must be passed through with the PEM\-encoded client SSL
  225. certificate
  226. .IP \(bu 2
  227. The proxy must request the client SSL certificate but not require it to be
  228. signed by a trusted CA.
  229. .UNINDENT
  230. .SS Nginx
  231. .sp
  232. These three lines in the configuration take care of the last three requirements
  233. listed above:
  234. .INDENT 0.0
  235. .INDENT 3.5
  236. .sp
  237. .nf
  238. .ft C
  239. proxy_set_header X\-Forwarded\-For $proxy_add_x_forwarded_for;
  240. proxy_set_header X\-SSL\-Cert $ssl_client_cert;
  241. ssl_verify_client optional_no_ca;
  242. .ft P
  243. .fi
  244. .UNINDENT
  245. .UNINDENT
  246. .sp
  247. The following is a complete example Nginx configuration file. With this setup,
  248. clients can use \fI\%https://discovery.example.com\fP as the discovery server URL in
  249. the Syncthing settings.
  250. .INDENT 0.0
  251. .INDENT 3.5
  252. .sp
  253. .nf
  254. .ft C
  255. # HTTP 1.1 support
  256. proxy_http_version 1.1;
  257. proxy_buffering off;
  258. proxy_set_header Host $http_host;
  259. proxy_set_header Upgrade $http_upgrade;
  260. proxy_set_header Connection $proxy_connection;
  261. proxy_set_header X\-Real\-IP $remote_addr;
  262. proxy_set_header X\-Forwarded\-For $proxy_add_x_forwarded_for;
  263. proxy_set_header X\-Forwarded\-Proto $proxy_x_forwarded_proto;
  264. proxy_set_header X\-SSL\-Cert $ssl_client_cert;
  265. upstream discovery.example.com {
  266. # Local IP address:port for discovery server
  267. server 192.0.2.1:8443;
  268. }
  269. server {
  270. server_name discovery.example.com;
  271. listen 80;
  272. access_log /var/log/nginx/access.log vhost;
  273. return 301 https://$host$request_uri;
  274. }
  275. server {
  276. server_name discovery.example.com;
  277. listen 443 ssl http2;
  278. access_log /var/log/nginx/access.log vhost;
  279. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  280. 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;
  281. ssl_prefer_server_ciphers on;
  282. ssl_session_timeout 5m;
  283. ssl_session_cache shared:SSL:50m;
  284. ssl_certificate /etc/nginx/certs/discovery.example.com.crt;
  285. ssl_certificate_key /etc/nginx/certs/discovery.example.com.key;
  286. ssl_dhparam /etc/nginx/certs/discovery.example.com.dhparam.pem;
  287. add_header Strict\-Transport\-Security "max\-age=31536000";
  288. ssl_verify_client optional_no_ca;
  289. location / {
  290. proxy_pass http://discovery.example.com;
  291. }
  292. }
  293. .ft P
  294. .fi
  295. .UNINDENT
  296. .UNINDENT
  297. .sp
  298. An example of automating the SSL certificates and reverse\-proxying the Discovery
  299. Server and Syncthing using Nginx, \fI\%Let\(aqs 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>\&.
  300. .SH SEE ALSO
  301. .sp
  302. \fIsyncthing\-networking(7)\fP, \fIsyncthing\-faq(7)\fP
  303. .SH AUTHOR
  304. The Syncthing Authors
  305. .SH COPYRIGHT
  306. 2015, The Syncthing Authors
  307. .\" Generated by docutils manpage writer.
  308. .