Installing Nextcloud in the webroot of Nginx

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
janlang
Posts: 2
Joined: Sun Nov 08, 2020 3:17 pm

Installing Nextcloud in the webroot of Nginx

Post by janlang »

Hello Everybody,
I am currently trying to set up a Nextcloud for personal use on my raspberry pi 4 4gb.
I have no experience with any admin-work and this is the first raspi project of mine.
Anyhow dietpi seems to be a good option to run a nextcloud in slim and efficient way.

Since you can install it as optimised software everything seems pretty straight forward.

Since i want to reach the nextcloud from outside over a dedicated Domain i would link to reach the nextcloud directly over the Domain itself an not in a subdir.

So over "my.example.org" rather than "my.example.org/nextcloud".

Checking the nextcloud admin manual i realised that the nginx config files a not exactly how written in the admin manual and i cannot figure out what i have to change.

Where do i need to make changes to get rid of the "/nextcloud"

Thank you in advance,
Jannik
User avatar
Joulinar
Posts: 2572
Joined: Sat Nov 16, 2019 12:49 am

Re: Installing Nextcloud in the webroot of Nginx

Post by Joulinar »

Hi,

many thanks for your question. If a simple redirect is okay just create an index.php into webroot /var/www with the following content

Code: Select all

<?php
header("Location: nextcloud");
?>
It just redirects the browser to the nextcloud folder, simple and easy.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
janlang
Posts: 2
Joined: Sun Nov 08, 2020 3:17 pm

Re: Installing Nextcloud in the webroot of Nginx

Post by janlang »

Hello,

Thank you for your reply and help!
This would be a solution! I already had it working this way but then came back to trying via changing the configuration of the webserver as I also want to understand more how it works and achieve a clean solution. (not really time efficient i know :D)

Since the admin manual of nextcloud already mentions two different set ups for Nginx(one to run nextcloud in a subdir, and one to run in in the webroot). I thought it might not be complicated to change the configuration:
https://docs.nextcloud.com/server/stabl ... nginx.html
But no config file in /etc/nginx matched the code shown in the admin manual, only parts of it.

Could you run me through the different points that need to be changed or would you argue that this would be way to advanced for someone without experience.
If its easier with using apache as webserver this would also be an option for me.

This is also about learning for me so any tips are well appreciated!

Greetz Jannik
User avatar
Joulinar
Posts: 2572
Joined: Sat Nov 16, 2019 12:49 am

Re: Installing Nextcloud in the webroot of Nginx

Post by Joulinar »

yes indeed, on DietPi thinks are split into a couple of configurations files to be flexible. Because the web server can be used for quite a lot of other web applications as well. Therefore /etc/nginx/nginx.conf is looking quite different than the one from NectCloud docs.

Let me try to explain the setup
  1. /etc/nginx/nginx.conf: just a base config that is going to include other config file

    Code: Select all

            include /etc/nginx/conf.d/*.conf;
            include /etc/nginx/sites-enabled/*;
  2. /etc/nginx/sites-enabled: this folder contains all configs that are activated. All files on this directory are linked to /etc/nginx/sites-available/
  3. /etc/nginx/sites-available/default: defines the web server port and include DietPi specific config files

    Code: Select all

            include /etc/nginx/sites-dietpi/*.conf;
  4. /etc/nginx/sites-dietpi: there you will find the NextCloud config file dietpi-nextcloud.conf
  5. /etc/nginx/sites-dietpi/dietpi-nextcloud.conf: there you have all NextCloud related configurations. Well some hardening and optization.
So easiest way is to create the index.php. There you will stay with DietPi default configuration.

Another option would be to change document root directory on /etc/nginx/sites-available/default. However I'm not sure if there are any side effects. Probably @MichaIng knows. At least you will loss possibilities to use the web server for something else.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 2422
Joined: Sat Nov 18, 2017 6:21 pm

Re: Installing Nextcloud in the webroot of Nginx

Post by MichaIng »

When changing the servers document root, you need to edit /var/www/nextcloud/config/config.php
On 'overwrite.cli.url' remove the trailing /nextcloud from the URL.
Post Reply