]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - doc/Server-configuration.md
Bump version to v0.8.1
[github/shaarli/Shaarli.git] / doc / Server-configuration.md
index c9ec4e137861839ae8415d5ec16817ec2440683a..df10feb255b4321ac8312a5b3c04d186cd188af8 100644 (file)
@@ -2,19 +2,29 @@
 *Example virtual host configurations for popular web servers*
 
 - [Apache](#apache)[](.html)
-- [LightHttpd](#lighthttpd) (empty)[](.html)
 - [Nginx](#nginx)[](.html)
 
 ## Prerequisites
+### Shaarli
 * Shaarli is installed in a directory readable/writeable by the user
 * the correct read/write permissions have been granted to the web server _user and/or group_
 * for HTTPS / SSL:
  * a key pair (public, private) and a certificate have been generated
  * the appropriate server SSL extension is installed and active
 
+### HTTPS, TLS and self-signed certificates
 Related guides:
 * [How to Create Self-Signed SSL Certificates with OpenSSL](http://www.xenocafe.com/tutorials/linux/centos/openssl/self_signed_certificates/index.php)[](.html)
 * [How do I create my own Certificate Authority?](https://workaround.org/certificate-authority)[](.html)
+* Generate a self-signed certificate (will trigger browser warnings) with apache2: `make-ssl-cert generate-default-snakeoil --force-overwrite` will create `/etc/ssl/certs/ssl-cert-snakeoil.pem` and `/etc/ssl/private/ssl-cert-snakeoil.key`
+
+### Proxies
+If Shaarli is served behind a proxy (i.e. there is a proxy server between clients and the web server hosting Shaarli), please refer to the proxy server documentation for proper configuration. In particular, you have to ensure that the following server variables are properly set:
+- `X-Forwarded-Proto`;
+- `X-Forwarded-Host`;
+- `X-Forwarded-For`.
+
+See also [proxy-related](https://github.com/shaarli/Shaarli/issues?utf8=%E2%9C%93&q=label%3Aproxy+) issues.[](.html)
 
 ## Apache
 ### Minimal
@@ -29,7 +39,7 @@ This configuration will log both Apache and PHP errors, which may prove useful t
 
 See:
 * [Apache/PHP - error log per VirtualHost](http://stackoverflow.com/q/176) (StackOverflow)[](.html)
-* [PHP: php_value vs php_admin_value and the use of php_flag explained](PHP: php_value vs php_admin_value and the use of php_flag explained)[](.html)
+* [PHP: php_value vs php_admin_value and the use of php_flag explained](https://ma.ttias.be/php-php_value-vs-php_admin_value-and-the-use-of-php_flag-explained/)[](.html)
 
 ```apache
 <VirtualHost *:80>
@@ -68,7 +78,7 @@ See [Server-side TLS](https://wiki.mozilla.org/Security/Server_Side_TLS#Apache)
     DocumentRoot /absolute/path/to/shaarli/
 
     SSLEngine             on
-    SSLCertificateFile    /absolute/path/to/the/website/certificate.crt
+    SSLCertificateFile    /absolute/path/to/the/website/certificate.pem
     SSLCertificateKeyFile /absolute/path/to/the/website/key.key
 
     <Directory /absolute/path/to/shaarli/>
@@ -92,6 +102,12 @@ See [Server-side TLS](https://wiki.mozilla.org/Security/Server_Side_TLS#Apache)
 </VirtualHost>
 ```
 
+### .htaccess
+
+Shaarli use `.htaccess` Apache files to deny access to files that shouldn't be directly accessed (datastore, config, etc.). You need the directive `AllowOverride All` in your virtual host configuration for them to work.
+
+**Warning**: If you use Apache 2.2 or lower, you need [mod_version](https://httpd.apache.org/docs/current/mod/mod_version.html) to be installed and enabled.[](.html)
+
 ## LightHttpd
 
 ## Nginx
@@ -126,7 +142,7 @@ On a development server:
 - files may be located in a user's home directory
 - in this case, make sure both Nginx and PHP-FPM are running as the local user/group!
 
-For all following examples, a development configuration will be used:
+For all following configuration examples, this user/group pair will be used:
 - `user:group = john:users`,
 
 which corresponds to the following service configuration:
@@ -150,6 +166,32 @@ http {
 }
 ```
 
+### (Optional) Increase the maximum file upload size
+Some bookmark dumps generated by web browsers can be _huge_ due to the presence of Base64-encoded images and favicons, as well as extra verbosity when nesting links in (sub-)folders.
+
+To increase upload size, you will need to modify both nginx and PHP configuration:
+
+```nginx
+# /etc/nginx/nginx.conf
+
+http {
+    [...][](.html)
+
+    client_max_body_size 10m;
+
+    [...][](.html)
+}
+```
+
+```ini
+# /etc/php5/fpm/php.ini
+
+[...][](.html)
+post_max_size = 10M
+[...][](.html)
+upload_max_filesize = 10M
+```
+
 ### Minimal
 _WARNING: Use for development only!_ 
 
@@ -219,11 +261,16 @@ location ~ ~$ {
 ```nginx
 # /etc/nginx/php.conf
 location ~ (index)\.php$ {
-    # proxy PHP requests to PHP-FPM
+    # filter and proxy PHP requests to PHP-FPM
     fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
     fastcgi_index  index.php;
     include        fastcgi.conf;
 }
+
+location ~ \.php$ {
+    # deny access to all other PHP scripts
+    deny all;
+}
 ```
 
 ```nginx
@@ -256,6 +303,11 @@ http {
             error_log   /var/log/nginx/shaarli.error.log;
         }
 
+        location = /shaarli/favicon.ico {
+            # serve the Shaarli favicon from its custom location
+            alias /var/www/shaarli/images/favicon.ico;
+        }
+
         include deny.conf;
         include static_assets.conf;
         include php.conf;
@@ -313,6 +365,11 @@ http {
             error_log   /var/log/nginx/shaarli.error.log;
         }
 
+        location = /shaarli/favicon.ico {
+            # serve the Shaarli favicon from its custom location
+            alias /var/www/shaarli/images/favicon.ico;
+        }
+
         include deny.conf;
         include static_assets.conf;
         include php.conf;