index.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. <!DOCTYPE html>
  2. <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
  3. <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
  4. <head>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <link rel="shortcut icon" href="../img/favicon.ico">
  9. <title>Server security - Shaarli Documentation</title>
  10. <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>
  11. <link rel="stylesheet" href="../css/theme.css" type="text/css" />
  12. <link rel="stylesheet" href="../css/theme_extra.css" type="text/css" />
  13. <link rel="stylesheet" href="../css/highlight.css">
  14. <link href="../github-markdown.css" rel="stylesheet">
  15. <script>
  16. // Current page data
  17. var mkdocs_page_name = "Server security";
  18. var mkdocs_page_input_path = "Server-security.md";
  19. var mkdocs_page_url = "/Server-security/";
  20. </script>
  21. <script src="../js/jquery-2.1.1.min.js"></script>
  22. <script src="../js/modernizr-2.8.3.min.js"></script>
  23. <script type="text/javascript" src="../js/highlight.pack.js"></script>
  24. </head>
  25. <body class="wy-body-for-nav" role="document">
  26. <div class="wy-grid-for-nav">
  27. <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
  28. <div class="wy-side-nav-search">
  29. <a href=".." class="icon icon-home"> Shaarli Documentation</a>
  30. <div role="search">
  31. <form id ="rtd-search-form" class="wy-form" action="../search.html" method="get">
  32. <input type="text" name="q" placeholder="Search docs" />
  33. </form>
  34. </div>
  35. </div>
  36. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  37. <ul class="current">
  38. <li class="toctree-l1">
  39. <a class="" href="..">Home</a>
  40. </li>
  41. <li class="toctree-l1">
  42. <span class="caption-text">Setup</span>
  43. <ul class="subnav">
  44. <li class="">
  45. <a class="" href="../Download-and-Installation/">Download and Installation</a>
  46. </li>
  47. <li class="">
  48. <a class="" href="../Upgrade-and-migration/">Upgrade and migration</a>
  49. </li>
  50. <li class="">
  51. <a class="" href="../Server-requirements/">Server requirements</a>
  52. </li>
  53. <li class="">
  54. <a class="" href="../Server-configuration/">Server configuration</a>
  55. </li>
  56. <li class=" current">
  57. <a class="current" href="./">Server security</a>
  58. <ul class="subnav">
  59. <li class="toctree-l3"><a href="#phpini">php.ini</a></li>
  60. <ul>
  61. <li><a class="toctree-l4" href="#locate-ini-files">Locate .ini files</a></li>
  62. </ul>
  63. <li class="toctree-l3"><a href="#fail2ban">fail2ban</a></li>
  64. <ul>
  65. <li><a class="toctree-l4" href="#read-shaarli-logs-to-ban-ips">Read Shaarli logs to ban IPs</a></li>
  66. </ul>
  67. <li class="toctree-l3"><a href="#robots-restricting-search-engines-and-web-crawler-traffic">Robots - Restricting search engines and web crawler traffic</a></li>
  68. </ul>
  69. </li>
  70. <li class="">
  71. <a class="" href="../Shaarli-configuration/">Shaarli configuration</a>
  72. </li>
  73. <li class="">
  74. <a class="" href="../Plugins/">Plugins</a>
  75. </li>
  76. </ul>
  77. </li>
  78. <li class="toctree-l1">
  79. <span class="caption-text">Docker</span>
  80. <ul class="subnav">
  81. <li class="">
  82. <a class="" href="../docker/docker-101/">Docker 101</a>
  83. </li>
  84. <li class="">
  85. <a class="" href="../docker/shaarli-images/">Shaarli images</a>
  86. </li>
  87. <li class="">
  88. <a class="" href="../docker/reverse-proxy-configuration/">Reverse proxy configuration</a>
  89. </li>
  90. <li class="">
  91. <a class="" href="../docker/resources/">Docker resources</a>
  92. </li>
  93. </ul>
  94. </li>
  95. <li class="toctree-l1">
  96. <span class="caption-text">Usage</span>
  97. <ul class="subnav">
  98. <li class="">
  99. <a class="" href="../Features/">Features</a>
  100. </li>
  101. <li class="">
  102. <a class="" href="../Bookmarklet/">Bookmarklet</a>
  103. </li>
  104. <li class="">
  105. <a class="" href="../Browsing-and-searching/">Browsing and searching</a>
  106. </li>
  107. <li class="">
  108. <a class="" href="../Firefox-share/">Firefox share</a>
  109. </li>
  110. <li class="">
  111. <a class="" href="../RSS-feeds/">RSS feeds</a>
  112. </li>
  113. <li class="">
  114. <a class="" href="../REST-API/">REST API</a>
  115. </li>
  116. </ul>
  117. </li>
  118. <li class="toctree-l1">
  119. <span class="caption-text">How To</span>
  120. <ul class="subnav">
  121. <li class="">
  122. <a class="" href="../Backup,-restore,-import-and-export/">Backup, restore, import and export</a>
  123. </li>
  124. <li class="">
  125. <a class="" href="../Various-hacks/">Various hacks</a>
  126. </li>
  127. </ul>
  128. </li>
  129. <li class="toctree-l1">
  130. <a class="" href="../Troubleshooting/">Troubleshooting</a>
  131. </li>
  132. <li class="toctree-l1">
  133. <span class="caption-text">Development</span>
  134. <ul class="subnav">
  135. <li class="">
  136. <a class="" href="../Development-guidelines/">Development guidelines</a>
  137. </li>
  138. <li class="">
  139. <a class="" href="../Continuous-integration-tools/">Continuous integration tools</a>
  140. </li>
  141. <li class="">
  142. <a class="" href="../GnuPG-signature/">GnuPG signature</a>
  143. </li>
  144. <li class="">
  145. <a class="" href="../Coding-guidelines/">Coding guidelines</a>
  146. </li>
  147. <li class="">
  148. <a class="" href="../Directory-structure/">Directory structure</a>
  149. </li>
  150. <li class="">
  151. <a class="" href="../3rd-party-libraries/">3rd party libraries</a>
  152. </li>
  153. <li class="">
  154. <a class="" href="../Plugin-System/">Plugin System</a>
  155. </li>
  156. <li class="">
  157. <a class="" href="../Release-Shaarli/">Release Shaarli</a>
  158. </li>
  159. <li class="">
  160. <a class="" href="../Versioning-and-Branches/">Versioning and Branches</a>
  161. </li>
  162. <li class="">
  163. <a class="" href="../Security/">Security</a>
  164. </li>
  165. <li class="">
  166. <a class="" href="../Static-analysis/">Static analysis</a>
  167. </li>
  168. <li class="">
  169. <a class="" href="../Theming/">Theming</a>
  170. </li>
  171. <li class="">
  172. <a class="" href="../Unit-tests/">Unit tests</a>
  173. </li>
  174. </ul>
  175. </li>
  176. <li class="toctree-l1">
  177. <span class="caption-text">About</span>
  178. <ul class="subnav">
  179. <li class="">
  180. <a class="" href="../FAQ/">FAQ</a>
  181. </li>
  182. <li class="">
  183. <a class="" href="../Community-&-Related-software/">Community & Related software</a>
  184. </li>
  185. </ul>
  186. </li>
  187. </ul>
  188. </div>
  189. &nbsp;
  190. </nav>
  191. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  192. <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
  193. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  194. <a href="..">Shaarli Documentation</a>
  195. </nav>
  196. <div class="wy-nav-content">
  197. <div class="rst-content">
  198. <div role="navigation" aria-label="breadcrumbs navigation">
  199. <ul class="wy-breadcrumbs">
  200. <li><a href="..">Docs</a> &raquo;</li>
  201. <li>Setup &raquo;</li>
  202. <li>Server security</li>
  203. <li class="wy-breadcrumbs-aside">
  204. <a href="https://github.com/shaarli/Shaarli/edit/master/docs/Server-security.md"
  205. class="icon icon-github"> Edit on GitHub</a>
  206. </li>
  207. </ul>
  208. <hr/>
  209. </div>
  210. <div role="main">
  211. <div class="section">
  212. <h2 id="phpini">php.ini</h2>
  213. <p>PHP settings are defined in:
  214. - a main configuration file, usually found under <code>/etc/php5/php.ini</code>; some distributions provide different configuration environments, e.g.
  215. - <code>/etc/php5/php.ini</code> - used when running console scripts
  216. - <code>/etc/php5/apache2/php.ini</code> - used when a client requests PHP resources from Apache
  217. - <code>/etc/php5/php-fpm.conf</code> - used when PHP requests are proxied to PHP-FPM
  218. - additional configuration files/entries, depending on the installed/enabled extensions:
  219. - <code>/etc/php/conf.d/xdebug.ini</code></p>
  220. <h3 id="locate-ini-files">Locate .ini files</h3>
  221. <h4 id="console-environment">Console environment</h4>
  222. <pre><code class="bash">$ php --ini
  223. Configuration File (php.ini) Path: /etc/php
  224. Loaded Configuration File: /etc/php/php.ini
  225. Scan for additional .ini files in: /etc/php/conf.d
  226. Additional .ini files parsed: /etc/php/conf.d/xdebug.ini
  227. </code></pre>
  228. <h4 id="server-environment">Server environment</h4>
  229. <ul>
  230. <li>create a <code>phpinfo.php</code> script located in a path supported by the web server, e.g.<ul>
  231. <li>Apache (with user dirs enabled): <code>/home/myself/public_html/phpinfo.php</code></li>
  232. <li><code>/var/www/test/phpinfo.php</code></li>
  233. </ul>
  234. </li>
  235. <li>make sure the script is readable by the web server user/group (usually, <code>www</code>, <code>www-data</code> or <code>httpd</code>)</li>
  236. <li>access the script from a web browser</li>
  237. <li>look at the <em>Loaded Configuration File</em> and <em>Scan this dir for additional .ini files</em> entries</li>
  238. </ul>
  239. <pre><code class="php">&lt;?php phpinfo(); ?&gt;
  240. </code></pre>
  241. <h2 id="fail2ban">fail2ban</h2>
  242. <p><code>fail2ban</code> is an intrusion prevention framework that reads server (Apache, SSH, etc.) and uses <code>iptables</code> profiles to block brute-force attempts:
  243. - <a href="http://www.fail2ban.org/wiki/index.php/Main_Page">Official website</a>
  244. - <a href="https://github.com/fail2ban/fail2ban">Source code</a></p>
  245. <h3 id="read-shaarli-logs-to-ban-ips">Read Shaarli logs to ban IPs</h3>
  246. <p>Example configuration:
  247. - allow 3 login attempts per IP address
  248. - after 3 failures, permanently ban the corresponding IP adddress</p>
  249. <p><code>/etc/fail2ban/jail.local</code></p>
  250. <pre><code class="ini">[shaarli-auth]
  251. enabled = true
  252. port = https,http
  253. filter = shaarli-auth
  254. logpath = /var/www/path/to/shaarli/data/log.txt
  255. maxretry = 3
  256. bantime = -1
  257. </code></pre>
  258. <p><code>/etc/fail2ban/filter.d/shaarli-auth.conf</code></p>
  259. <pre><code class="ini">[INCLUDES]
  260. before = common.conf
  261. [Definition]
  262. failregex = \s-\s&lt;HOST&gt;\s-\sLogin failed for user.*$
  263. ignoreregex =
  264. </code></pre>
  265. <h2 id="robots-restricting-search-engines-and-web-crawler-traffic">Robots - Restricting search engines and web crawler traffic</h2>
  266. <p>Creating a <code>robots.txt</code> with the following contents at the root of your Shaarli installation will prevent <em>honest</em> web crawlers from indexing each and every link and Daily page from a Shaarli instance, thus getting rid of a certain amount of unsollicited network traffic.</p>
  267. <pre><code>User-agent: *
  268. Disallow: /
  269. </code></pre>
  270. <p>See:
  271. - http://www.robotstxt.org/
  272. - http://www.robotstxt.org/robotstxt.html
  273. - http://www.robotstxt.org/meta.html</p>
  274. </div>
  275. </div>
  276. <footer>
  277. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  278. <a href="../Shaarli-configuration/" class="btn btn-neutral float-right" title="Shaarli configuration">Next <span class="icon icon-circle-arrow-right"></span></a>
  279. <a href="../Server-configuration/" class="btn btn-neutral" title="Server configuration"><span class="icon icon-circle-arrow-left"></span> Previous</a>
  280. </div>
  281. <hr/>
  282. <div role="contentinfo">
  283. <!-- Copyright etc -->
  284. </div>
  285. Built with <a href="http://www.mkdocs.org">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
  286. </footer>
  287. </div>
  288. </div>
  289. </section>
  290. </div>
  291. <div class="rst-versions" role="note" style="cursor: pointer">
  292. <span class="rst-current-version" data-toggle="rst-current-version">
  293. <a href="https://github.com/shaarli/Shaarli" class="fa fa-github" style="float: left; color: #fcfcfc"> GitHub</a>
  294. <span><a href="../Server-configuration/" style="color: #fcfcfc;">&laquo; Previous</a></span>
  295. <span style="margin-left: 15px"><a href="../Shaarli-configuration/" style="color: #fcfcfc">Next &raquo;</a></span>
  296. </span>
  297. </div>
  298. <script src="../js/theme.js"></script>
  299. </body>
  300. </html>