This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| virtualisation:nextcloud [2018/02/27 14:16] – buettner | virtualisation:nextcloud [2018/03/01 09:19] (current) – buettner | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====How to setup Nextcloud on a NB2800 router==== | + | ======How to setup Nextcloud on a NB2800 router====== |
| This article describes how to setup a Nextcloud server on your NB2800 router. | This article describes how to setup a Nextcloud server on your NB2800 router. | ||
| - | [[https:// | + | [[https:// |
| ===Preparations=== | ===Preparations=== | ||
| - | |||
| - | All basic preparations made are described in this article: [[http:// | ||
| If you need instructions on how to set up a LXC Container on NB2800 Routers, you can refer to this page: http:// | If you need instructions on how to set up a LXC Container on NB2800 Routers, you can refer to this page: http:// | ||
| + | |||
| + | The first step you should take is to give your router a static IP adress. For this, use | ||
| + | < | ||
| + | nano / | ||
| + | </ | ||
| + | and set up a static IP configuration for your primary interface. In this example, the configuration for the eth0 interface looks like this: | ||
| + | < | ||
| + | auto eth0 | ||
| + | iface eth0 inet static | ||
| + | address 192.168.1.50 | ||
| + | netmask 255.255.255.0 | ||
| + | network 192.168.1.0 | ||
| + | broadcast 192.168.1.255 | ||
| + | gateway 192.168.1.105 | ||
| + | dns-nameservers 192.168.1.105 | ||
| + | </ | ||
| + | |||
| + | After that, use | ||
| + | < | ||
| + | apt-get update | ||
| + | apt-get upgrade | ||
| + | </ | ||
| + | to bring your system up to date. | ||
| + | |||
| + | If your network setup doesn' | ||
| + | |||
| + | For this, get access to the routers web interface and go to Services -> DNS Server. Under " | ||
| + | |||
| + | Now enter the IP address and the domain name you want it linked to and click " | ||
| + | {{ : | ||
| + | |||
| + | |||
| + | After this, your configuration should look like this: | ||
| + | |||
| + | {{ : | ||
| + | |||
| + | Now you can access the file server with both its IP address a its local domain name. | ||
| + | |||
| ===Installations=== | ===Installations=== | ||
| - | Before Nextcloud can be installed, | + | Before Nextcloud can be installed, |
| < | < | ||
| + | apt-get update | ||
| apt-get install nginx mariadb-client mariadb-server php7.0-common php7.0-fpm php7.0-cli php7.0-json php7.0-mysql php7.0-curl php7.0-intl php7.0-mcrypt php-pear php7.0-gd php7.0-zip php7.0-xml php7.0-mbstring php7.0-apcu | apt-get install nginx mariadb-client mariadb-server php7.0-common php7.0-fpm php7.0-cli php7.0-json php7.0-mysql php7.0-curl php7.0-intl php7.0-mcrypt php-pear php7.0-gd php7.0-zip php7.0-xml php7.0-mbstring php7.0-apcu | ||
| </ | </ | ||
| Line 25: | Line 62: | ||
| ===Configuring PHP=== | ===Configuring PHP=== | ||
| - | For setting up PHP, several values in three files have to be edited. First, go to / | + | For setting up PHP, several values in three files have to be edited. First, go to / |
| <code c / | <code c / | ||
| user = www-data | user = www-data | ||
| Line 63: | Line 100: | ||
| ===Configuring MariaDB=== | ===Configuring MariaDB=== | ||
| - | First, you have to finish the MariDB | + | First, you have to finish the MariaDB |
| < | < | ||
| mysql_secure_installation | mysql_secure_installation | ||
| Line 73: | Line 110: | ||
| service mysql restart | service mysql restart | ||
| </ | </ | ||
| - | Now you have to create a new MariaDB user which is only needed for Nextcloud access. To enter the MariaDB | + | Now you have to create a new MariaDB |
| < | < | ||
| mysql -u root -p | mysql -u root -p | ||
| Line 81: | Line 118: | ||
| create database nextcloud_db; | create database nextcloud_db; | ||
| </ | </ | ||
| - | Now create a new MariaDB-user with a password which can access the " | + | Now create a new MariaDB user with a password which can access the " |
| < | < | ||
| create user ' | create user ' | ||
| Line 87: | Line 124: | ||
| Note that you have to enter your own credentials for ' | Note that you have to enter your own credentials for ' | ||
| - | Now all necessary | + | Now all necessary |
| < | < | ||
| grant all privileges on nextcloud_db.* to ' | grant all privileges on nextcloud_db.* to ' | ||
| Line 114: | Line 151: | ||
| First, go to / | First, go to / | ||
| <code c / | <code c / | ||
| - | überprüfen ob user = www-data | + | user = www-data |
| - | überprüfen ob worker_process = auto | + | worker_process = auto |
| - | in html-Block: | + | server_tokens off |
| </ | </ | ||
| Line 127: | Line 164: | ||
| nano / | nano / | ||
| </ | </ | ||
| - | This new file has to be filled with this code: | + | This new file has to be filled with this code (All passages that need to be edited are marked in the code): |
| <code c / | <code c / | ||
| upstream php-handler { | upstream php-handler { | ||
| Line 135: | Line 172: | ||
| server { | server { | ||
| listen 80; | listen 80; | ||
| - | server_name mediacontainer.local; | + | server_name mediacontainer.local; |
| # enforce https | # enforce https | ||
| return 301 https:// | return 301 https:// | ||
| Line 142: | Line 179: | ||
| server { | server { | ||
| listen 443 ssl http2; | listen 443 ssl http2; | ||
| - | server_name mediacontainer.local; | + | server_name mediacontainer.local; |
| - | ssl_certificate /home/User/CA/cert.pem; c und Dateinamen anpassen | + | ssl_certificate /home/NCUser/CA/cacert.pem; //* edit to own files and directorys *// |
| - | ssl_certificate_key /home/User/ | + | ssl_certificate_key /home/NCUser/ |
| # Add headers to serve security related headers | # Add headers to serve security related headers | ||
| Line 165: | Line 202: | ||
| # Path to the root of your installation | # Path to the root of your installation | ||
| - | root / | + | root / |
| - | server unix:/ | + | |
| - | } | + | |
| - | + | ||
| - | server { | + | |
| - | listen 80; | + | |
| - | server_name mediacontainer.local; //an aktuellen Domainnamen anpassen | + | |
| - | # enforce https | + | |
| - | return 301 https:// | + | |
| - | } | + | |
| - | + | ||
| - | server { | + | |
| - | listen 443 ssl http2; | + | |
| - | server_name mediacontainer.local; | + | |
| - | + | ||
| - | ssl_certificate / | + | |
| - | ssl_certificate_key / | + | |
| - | + | ||
| - | # Add headers | + | |
| - | # Before enabling Strict-Transport-Security headers please read into this | + | |
| - | # topic first. | + | |
| - | add_header Strict-Transport-Security " | + | |
| - | # includeSubDomains; | + | |
| - | # | + | |
| - | # WARNING: Only add the preload option once you read about | + | |
| - | # the consequences in https:// | + | |
| - | # will add the domain to a hardcoded list that is shipped | + | |
| - | # in all major browsers and getting removed from this list | + | |
| - | # could take several months. | + | |
| - | add_header X-Content-Type-Options nosniff; | + | |
| - | add_header X-XSS-Protection "1; mode=block"; | + | |
| - | add_header X-Robots-Tag none; | + | |
| - | add_header X-Download-Options noopen; | + | |
| - | add_header X-Permitted-Cross-Domain-Policies none; | + | |
| - | + | ||
| - | # Path to the root of your installation | + | |
| - | root / | + | |
| - | server unix:/ | + | |
| - | } | + | |
| - | + | ||
| - | server { | + | |
| - | listen 80; | + | |
| - | server_name mediacontainer.local; | + | |
| - | # enforce https | + | |
| - | return 301 https:// | + | |
| - | } | + | |
| - | + | ||
| - | server { | + | |
| - | listen 443 ssl http2; | + | |
| - | server_name mediacontainer.local; | + | |
| - | + | ||
| - | ssl_certificate / | + | |
| - | ssl_certificate_key / | + | |
| - | + | ||
| - | # Add headers to serve security related headers | + | |
| - | # Before enabling Strict-Transport-Security headers please read into this | + | |
| - | # topic first. | + | |
| - | add_header Strict-Transport-Security " | + | |
| - | # includeSubDomains; | + | |
| - | # | + | |
| - | # WARNING: Only add the preload option once you read about | + | |
| - | # the consequences in https:// | + | |
| - | # will add the domain to a hardcoded list that is shipped | + | |
| - | # in all major browsers and getting removed from this list | + | |
| - | # could take several months. | + | |
| - | add_header X-Content-Type-Options nosniff; | + | |
| - | add_header X-XSS-Protection "1; mode=block"; | + | |
| - | add_header X-Robots-Tag none; | + | |
| - | add_header X-Download-Options noopen; | + | |
| - | add_header X-Permitted-Cross-Domain-Policies none; | + | |
| - | + | ||
| - | # Path to the root of your installation | + | |
| - | root / | + | |
| location = /robots.txt { | location = /robots.txt { | ||
| Line 336: | Line 301: | ||
| } | } | ||
| } | } | ||
| + | </ | ||
| - | location = /robots.txt { | + | Now you can test your Nginx configuration by entering |
| - | allow all; | + | < |
| - | | + | nginx -t |
| - | | + | </ |
| - | } | + | |
| - | # The following 2 rules are only needed for the user_webfinger app. | + | < |
| - | # Uncomment it if you're planning to use this app. | + | root@LXC_MEDIA:/ |
| - | # | + | nginx: the configuration file /etc/nginx/nginx.conf syntax is ok |
| - | # | + | nginx: configuration file /etc/nginx/nginx.conf test is successful |
| - | # last; | + | </ |
| - | location = / | + | If no error occurs, restart Nginx with |
| - | | + | < |
| - | } | + | service nginx restart |
| - | | + | </code> |
| - | return 301 $scheme:// | + | |
| - | } | + | |
| - | # set max upload size | ||
| - | client_max_body_size 512M; | ||
| - | fastcgi_buffers 64 4K; | ||
| - | # Enable gzip but do not remove ETag headers | + | ===Nextcloud Download and Installation=== |
| - | gzip on; | + | |
| - | gzip_vary on; | + | |
| - | gzip_comp_level 4; | + | |
| - | gzip_min_length 256; | + | |
| - | gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; | + | |
| - | gzip_types application/ | + | |
| - | | + | First, download the Nextcloud installation file from the Nextcloud homepage. Before downloading the file, you should visit the [[https:// |
| - | # This module is currently not supported. | + | < |
| - | # | + | wget https:// |
| + | </ | ||
| + | After the download finished, extract the file to its directory: | ||
| + | < | ||
| + | tar -xjf nextcloud-13.0.0.tar.bz2 -C /var/www | ||
| + | </ | ||
| + | If you want to, you can now delete the installation file: | ||
| + | < | ||
| + | rm nextcloud-13.0.0.tar.bz2 | ||
| + | </ | ||
| + | Now you have to set the correct user and group to the Nextcloud folder: | ||
| + | < | ||
| + | chown -R www-data: | ||
| + | </ | ||
| - | location | + | Now open your web browser and go to http://Ip-address-or-domain to enter the Nextcloud installation screen. |
| - | rewrite ^ /index.php$uri; | + | |
| - | } | + | |
| - | location ~ ^/ | + | Here you have to set credentials for an administrator and enter the MariaDB user credentials you set earlier. |
| - | deny all; | + | |
| - | } | + | |
| - | location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { | + | |
| - | deny all; | + | |
| - | } | + | |
| - | location ~ ^/(?:index|remote|public|cron|core/ | + | {{ :virtualisation: |
| - | fastcgi_split_path_info ^(.+\.php)(/ | + | |
| - | include fastcgi_params; | + | |
| - | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | + | |
| - | fastcgi_param PATH_INFO $fastcgi_path_info; | + | |
| - | fastcgi_param HTTPS on; | + | |
| - | #Avoid sending the security headers twice | + | |
| - | fastcgi_param modHeadersAvailable true; | + | |
| - | fastcgi_param front_controller_active true; | + | |
| - | fastcgi_pass php-handler; | + | |
| - | fastcgi_intercept_errors on; | + | |
| - | fastcgi_request_buffering off; | + | |
| - | | + | |
| - | location ~ ^/ | ||
| - | try_files $uri/ =404; | ||
| - | index index.php; | ||
| - | } | ||
| - | # Adding the cache control header for js and css files | + | ===Configuration Nextcloud=== |
| - | # Make sure it is BELOW the PHP block | + | |
| - | location ~ \.(?: | + | |
| - | try_files $uri / | + | |
| - | add_header Cache-Control " | + | |
| - | # Add headers to serve security related headers (It is intended to | + | |
| - | # have those duplicated to the ones above) | + | |
| - | # Before enabling Strict-Transport-Security headers please read into | + | |
| - | # this topic first. | + | |
| - | # add_header Strict-Transport-Security " | + | |
| - | # includeSubDomains; | + | |
| - | # | + | |
| - | # WARNING: Only add the preload option once you read about | + | |
| - | # the consequences in https:// | + | |
| - | # will add the domain to a hardcoded list that is shipped | + | |
| - | # in all major browsers and getting removed from this list | + | |
| - | # could take several months. | + | |
| - | add_header X-Content-Type-Options nosniff; | + | |
| - | add_header X-XSS-Protection "1; mode=block"; | + | |
| - | add_header X-Robots-Tag none; | + | |
| - | add_header X-Download-Options noopen; | + | |
| - | add_header X-Permitted-Cross-Domain-Policies none; | + | |
| - | # Optional: Don't log access to assets | + | |
| - | access_log off; | + | |
| - | } | + | |
| - | location ~ \.(?: | + | After Nextcloud was installed succesfully, |
| - | try_files $uri / | + | <code c /var/www/nextcloud/config/config.php> |
| - | # Optional: Don't log access | + | ' |
| - | access_log off; | + | ' |
| - | } | + | array ( |
| - | } | + | 0 => ' |
| - | + | 1 => '192.168.1.50', | |
| - | location = /robots.txt { | + | ), |
| - | allow all; | + | ' |
| - | log_not_found off; | + | ' |
| - | access_log off; | + | |
| - | } | + | |
| - | + | ||
| - | # The following 2 rules are only needed for the user_webfinger app. | + | |
| - | # Uncomment it if you're planning to use this app. | + | |
| - | #rewrite ^/.well-known/host-meta | + | |
| - | #rewrite ^/.well-known/ | + | |
| - | # last; | + | |
| - | + | ||
| - | location = / | + | |
| - | return 301 $scheme:// | + | |
| - | } | + | |
| - | location = /.well-known/caldav { | + | |
| - | return 301 $scheme://$host/remote.php/dav; | + | |
| - | } | + | |
| - | + | ||
| - | # set max upload size | + | |
| - | client_max_body_size 512M; | + | |
| - | fastcgi_buffers 64 4K; | + | |
| - | + | ||
| - | # Enable gzip but do not remove ETag headers | + | |
| - | gzip on; | + | |
| - | gzip_vary on; | + | |
| - | gzip_comp_level 4; | + | |
| - | gzip_min_length 256; | + | |
| - | gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; | + | |
| - | gzip_types application/ | + | |
| - | + | ||
| - | # Uncomment if your server is build with the ngx_pagespeed module | + | |
| - | # This module is currently not supported. | + | |
| - | #pagespeed off; | + | |
| - | + | ||
| - | location / { | + | |
| - | rewrite ^ / | + | |
| - | } | + | |
| - | + | ||
| - | location ~ ^/ | + | |
| - | deny all; | + | |
| - | } | + | |
| - | location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { | + | |
| - | deny all; | + | |
| - | } | + | |
| - | + | ||
| - | location ~ ^/ | + | |
| - | fastcgi_split_path_info ^(.+\.php)(/ | + | |
| - | | + | |
| - | | + | |
| - | fastcgi_param PATH_INFO $fastcgi_path_info; | + | |
| - | fastcgi_param HTTPS on; | + | |
| - | #Avoid sending the security headers twice | + | |
| - | fastcgi_param modHeadersAvailable true; | + | |
| - | fastcgi_param front_controller_active true; | + | |
| - | fastcgi_pass php-handler; | + | |
| - | fastcgi_intercept_errors on; | + | |
| - | fastcgi_request_buffering off; | + | |
| - | } | + | |
| - | + | ||
| - | location ~ ^/(?: | + | |
| - | | + | |
| - | index index.php; | + | |
| - | } | + | |
| - | + | ||
| - | # Adding the cache control header for js and css files | + | |
| - | # Make sure it is BELOW the PHP block | + | |
| - | location ~ \.(?: | + | |
| - | try_files $uri /index.php$uri$is_args$args; | + | |
| - | add_header Cache-Control " | + | |
| - | # Add headers to serve security related headers (It is intended to | + | |
| - | # have those duplicated to the ones above) | + | |
| - | # Before enabling Strict-Transport-Security headers please read into | + | |
| - | # this topic first. | + | |
| - | # add_header Strict-Transport-Security " | + | |
| - | # includeSubDomains; | + | |
| - | # | + | |
| - | # WARNING: Only add the preload option once you read about | + | |
| - | # the consequences in https:// | + | |
| - | # will add the domain to a hardcoded list that is shipped | + | |
| - | # in all major browsers and getting removed from this list | + | |
| - | # could take several months. | + | |
| - | add_header X-Content-Type-Options nosniff; | + | |
| - | add_header X-XSS-Protection "1; mode=block"; | + | |
| - | add_header X-Robots-Tag none; | + | |
| - | add_header X-Download-Options noopen; | + | |
| - | add_header X-Permitted-Cross-Domain-Policies none; | + | |
| - | # Optional: Don't log access to assets | + | |
| - | access_log off; | + | |
| - | } | + | |
| - | + | ||
| - | location ~ \.(?: | + | |
| - | try_files $uri /index.php$uri$is_args$args; | + | |
| - | # Optional: Don't log access to other assets | + | |
| - | access_log off; | + | |
| - | } | + | |
| - | } | + | |
| </ | </ | ||