summaryrefslogtreecommitdiff
path: root/nextcloud_nginx.html
diff options
context:
space:
mode:
Diffstat (limited to 'nextcloud_nginx.html')
-rw-r--r--nextcloud_nginx.html344
1 files changed, 0 insertions, 344 deletions
diff --git a/nextcloud_nginx.html b/nextcloud_nginx.html
deleted file mode 100644
index ed6a3be..0000000
--- a/nextcloud_nginx.html
+++ /dev/null
@@ -1,344 +0,0 @@
-<!DOCTYPE html>
-<html lang=en>
- <head>
- <title>Nextcloud Server with Nginx&ndash; LandChad.net</title>
- <meta charset="utf-8"/>
- <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
- <link rel='stylesheet' type='text/css' href='style.css'>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel='alternate' type='application/rss+xml' title='Land Chad RSS' href='/rss.xml'>
- </head>
-<body>
- <header><h1>Nextcloud Server using Nginx</h1></header>
- <nav></nav>
- <main>
-
- <p>Nextcloud is by far the best (and in many ways only) free and open source cloud storage solution. Not only can the client be used on nearly all platforms such as desktop, android and IOS but it also doesn't take up much memory on your server.
- </p>
-
- <p>You'll need a server or VPS running a Debian-based OS (Ubuntu 20 or Debian 10 are recommended) and at least 512MB of RAM. You'll also need a domain name pointing to your server's IP address.
- </p>
-
- <p><b>
- Note that although I am using Nginx it's not officially supported.
- <a href="https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html"> More info here.</a>
- </b></p>
-
- <h2>Automatic Installation</h2>
- <p>If you want to just automatically do all the steps below then you can use my installation script
- <a href="https://github.com/BiasedRiot/SaorTech-cloud-services/blob/main/services/install_nextcloud.sh"> in my git repo linked here.</a>
- Or alternatively you can use the <a href="https://docs.nextcloud.com/server/latest/admin_manual/installation/installation_wizard.html">Nextcloud installation wizard in the official documentation</a> but I've found before that it fails if you don't have a certain amount of memory allocated.
- </p>
-
-<h2>Manual Installation</h2>
-
-<h3>Setting up Nginx and Mariadb</h3>
-
-<p>
-First thing we'll need to do is install the dependancies. We'll be using Mariadb and nginx for the server. Simply run the below command.
-</p>
-
-<pre><code>apt install nginx software-properties-common mariadb-server php7.3 php7.3-mysql</code></pre>
-
-<p>
-Enable and start the nginx systemD service with the below command:
-</p>
-
-<pre><code>systemctl start nginx
-systemctl enable nginx
-</code></pre>
-
-<p>
-Next run the mysql_secure_installation using the below command
-</p>
-
-<pre><code>
-mysql_secure_installation
-</code></pre>
-
-<p>
-Next run <code>mariadb</code> and enter the below SQL commands.
-</p>
-
-<pre><code>
-CREATE DATABASE nextcloud;
-CREATE USER nextcloud IDENTIFIED BY 'ENTER A SECURE PASSWORD';
-GRANT USAGE ON *.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'YOUR PASSWORD';
-GRANT ALL privileges ON nextcloud.* TO 'nextcloud'@'localhost';
-FLUSH PRIVILEGES;
-</code></pre>
-
-
-
-<h3>Installing the Nextcloud Application</h3>
-
-<p>
-First we'll install some more dependancies.
-</p>
-
-<pre><code>
-apt install php7.3-gd php7.3-json php7.3-mysql php7.3-curl php7.3-mbstring php7.3-intl php7.3-imagick php7.3-xml php7.3-zip
-</code></pre>
-
-<p>
-Next we'll install the nextcloud app and move the relevant files to your nginx server directory.
-</p>
-
-<pre><code>
-wget https://download.nextcloud.com/server/releases/nextcloud-15.0.7.tar.bz2
-tar -xvf nextcloud-15.0.7.tar.bz2
-cd nextcloud
-mkdir /var/www/nextcloud/
-
-mv ./* /var/www/nextcloud | mv ./.htaccess /var/www/nextcloud | mv ./.user.ini /var/www/nextcloud
-</code></pre>
-
-<p>
-Next we'll remove this installed directory and change the permissions.
-</p>
-
-<pre><code>
-cd /var/www/nextcloud
-rm -r ~/nextcloud/
-chown -R www-data:www-data ./*
-chown www-data:www-data .htaccess
-chown www-data:www-data .user.ini
-</code></pre>
-
-
-<h3>Setting Up Encryption (SSL)</h3>
-
-<p>
-Next we'll create an SSL certificate for your domain name. For tutorial purposes I'll use the domain <code>nextcloud.example.com</code>. Thanks to the EFF anyone can get an SSL certificate for free using Certbot.
-First we'll install the dependancies:
-</p>
-
-<pre><code>
-apt install certbot
-</code></pre>
-
-<p>
-Next you'll need to go to the file <code>/etc/nginx/sites-available/default</code> and change the section in <code>ServerName</code> from example.com to whatever your domain is.
-Then you can copy this file to the sites enabled with the below commands:
-</p>
-<pre><code>
-cp /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default
-systemctl restart nginx
-</code></pre>
-
-<p>
-Next run the below command to create your cert:
-</p>
-
-<pre><code>
-certbot -d $my_domain --redirect
-</code></pre>
-
-<h3>Housekeeping and security best practices</h3>
-<p>
-The remaining commands are just to make your server work/secure it as much as possible.
-First we'll need to create the directory for storing the data. We're doing it in the root directory so there's no chance of someone accessing it from the browser.
-</p>
-
-<pre><code>
-mkdir /nextcloud-data
-chown www-data:www-data /nextcloud-data
-chown www-data:www-data /nextcloud-data/
-</code></pre>
-
-<p>
-Next go to the <code>/etc/php/7.3/nginx/php.ini</code> and make the following changes.
-</p>
-
-<p>
-Change <strong>upload_max_filesize = 2M</strong> to <strong>512M</strong>
-</p>
-<p>Change <strong>memory_limit = 128M</strong> to <strong>512M</strong>
-</p>
-<p>Change <strong>post_max_size = 8M</strong> to <strong>512M</strong>
-</p>
-
-<p>
-Next go to the <code>/etc/nginx/sites-enabled/default</code> file and add the following to it:
-<b>NOTE:</b> You'll need to change the cloud.example.com in all places in the below to your domain.
-</p>
-
-<pre><code>
-server {
- listen 443 ssl http2;
- listen [::]:443 ssl http2;
- server_name cloud.example.com;
-
- # Use Mozilla's guidelines for SSL/TLS settings
- # https://mozilla.github.io/server-side-tls/ssl-config-generator/
- ssl_certificate /etc/ssl/nginx/cloud.example.com.crt;
- ssl_certificate_key /etc/ssl/nginx/cloud.example.com.key;
-
- # HSTS settings
- # WARNING: Only add the preload option once you read about
- # the consequences in https://hstspreload.org/. This option
- # 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 Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
-
- # 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/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
-
- # Pagespeed is not supported by Nextcloud, so if your server is built
- # with the `ngx_pagespeed` module, uncomment this line to disable it.
- #pagespeed off;
-
- # HTTP response headers borrowed from Nextcloud `.htaccess`
- add_header Referrer-Policy "no-referrer" always;
- add_header X-Content-Type-Options "nosniff" always;
- add_header X-Download-Options "noopen" always;
- add_header X-Frame-Options "SAMEORIGIN" always;
- add_header X-Permitted-Cross-Domain-Policies "none" always;
- add_header X-Robots-Tag "none" always;
- add_header X-XSS-Protection "1; mode=block" always;
-
- # Remove X-Powered-By, which is an information leak
- fastcgi_hide_header X-Powered-By;
-
- # Path to the root of your installation
- root /var/www/nextcloud;
-
- # Specify how to handle directories -- specifying `/index.php$request_uri`
- # here as the fallback means that Nginx always exhibits the desired behaviour
- # when a client requests a path that corresponds to a directory that exists
- # on the server. In particular, if that directory contains an index.php file,
- # that file is correctly served; if it doesn't, then the request is passed to
- # the front-end controller. This consistent behaviour means that we don't need
- # to specify custom rules for certain paths (e.g. images and other assets,
- # `/updater`, `/ocm-provider`, `/ocs-provider`), and thus
- # `try_files $uri $uri/ /index.php$request_uri`
- # always provides the desired behaviour.
- index index.php index.html /index.php$request_uri;
-
- # Rule borrowed from `.htaccess` to handle Microsoft DAV clients
- location = / {
- if ( $http_user_agent ~ ^DavClnt ) {
- return 302 /remote.php/webdav/$is_args$args;
- }
- }
-
- location = /robots.txt {
- allow all;
- log_not_found off;
- access_log off;
- }
-
- # Make a regex exception for `/.well-known` so that clients can still
- # access it despite the existence of the regex rule
- # `location ~ /(\.|autotest|...)` which would otherwise handle requests
- # for `/.well-known`.
- location ^~ /.well-known {
- # The rules in this block are an adaptation of the rules
- # in `.htaccess` that concern `/.well-known`.
-
- location = /.well-known/carddav { return 301 /remote.php/dav/; }
- location = /.well-known/caldav { return 301 /remote.php/dav/; }
-
- location /.well-known/acme-challenge { try_files $uri $uri/ =404; }
- location /.well-known/pki-validation { try_files $uri $uri/ =404; }
-
- # Let Nextcloud's API for `/.well-known` URIs handle all other
- # requests by passing them to the front-end controller.
- return 301 /index.php$request_uri;
- }
-
- # Rules borrowed from `.htaccess` to hide certain paths from clients
- location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; }
- location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; }
-
- # Ensure this block, which passes PHP files to the PHP process, is above the blocks
- # which handle static assets (as seen below). If this block is not declared first,
- # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php`
- # to the URI, resulting in a HTTP 500 error response.
- location ~ \.php(?:$|/) {
- fastcgi_split_path_info ^(.+?\.php)(/.*)$;
- set $path_info $fastcgi_path_info;
-
- try_files $fastcgi_script_name =404;
-
- include fastcgi_params;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- fastcgi_param PATH_INFO $path_info;
- fastcgi_param HTTPS on;
-
- fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice
- fastcgi_param front_controller_active true; # Enable pretty urls
- fastcgi_pass php-handler;
-
- fastcgi_intercept_errors on;
- fastcgi_request_buffering off;
- }
-
- location ~ \.(?:css|js|svg|gif)$ {
- try_files $uri /index.php$request_uri;
- expires 6M; # Cache-Control policy borrowed from `.htaccess`
- access_log off; # Optional: Don't log access to assets
- }
-
- location ~ \.woff2?$ {
- try_files $uri /index.php$request_uri;
- expires 7d; # Cache-Control policy borrowed from `.htaccess`
- access_log off; # Optional: Don't log access to assets
- }
-
- # Rule borrowed from `.htaccess`
- location /remote {
- return 301 /remote.php$request_uri;
- }
-
- location / {
- try_files $uri $uri/ /index.php$request_uri;
- }
-}
-
-</code></pre>
-
-<p>
-Then run the below commands and you should be all set:
-</p>
-
-<pre><code>
-systemctl restart nginx
-a2enmod headers
-
--u www-data php /var/www/html/./occ db:convert-filecache-bigint
-</code></pre>
-
-
-<p>
-If you run into any issues then <a href="https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html">feel free to checkout the documentation</a> or send me an email or message. My details are below.
-</p>
-
-<p>
-<b>My Website:</b> https://biasedriot.co
-</p>
-
-<p>
-<b>My Youtube Channel:</b> https://www.youtube.com/channel/UCehh50T6qtDpt_kEUF33GJw
-</p>
-
-<p>
-<b>Monero:</b> 84Y4FZiTbLeR5qc1fBrBhB1yq5agKtEdoixq2w1ysXJv486MiBCz3czGT15bqeXDPpdLoNyF93inxY3BCk6g8mrDMNKoArS
-</p>
-<p>
-<b>Bitcoin:</b> 1Dmn9jEtWAhdLk1HHWkUVNeDdAaBCwNajm
-</p>
- </main>
- <footer><a href="https://landchad.net">LandChad.net</a></br>Because Everyone should be an Internet LandChad.</br><li><a href="index.html"><img src="pix/chad.gif" alt="chad"></a></li><li><a href="rss.xml"><img src="pix/rss.svg" alt="RSS"></a></li><li><a href="pix/btc.png"><img src="pix/btc.svg" alt="BTC"></a></li><li><a href="pix/xmr.png"><img src="pix/xmr.svg" alt="XMR"></a></li><li><a href="https://github.com/lukesmithxyz/landchad"><img src="pix/git.svg" alt="Github"></a></footer>
-</body>
-</html>