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,
many thanks for your question. If a simple redirect is okay just create an index.php into webroot /var/www with the following content
It just redirects the browser to the nextcloud folder, simple and easy.
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 )
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:
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!
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
- /etc/nginx/nginx.conf: just a base config that is going to include other config file
- /etc/nginx/sites-enabled: this folder contains all configs that are activated. All files on this directory are linked to /etc/nginx/sites-available/
- /etc/nginx/sites-available/default: defines the web server port and include DietPi specific config files
- /etc/nginx/sites-dietpi: there you will find the NextCloud config file dietpi-nextcloud.conf
- /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.
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.
I had exactly the same wish for apache webserver, get rid of the /nextcloud in the url. I think a browser redirect is no option, since nextcloud apps (i.e. Android) don’t seem to follow these directives. I want to redirect on the server side to be sure.
I changed the document root for a certain virtualhost to /var/www/nextcloud.
I also made the change to /var/www/nextcloud/config/config.php.
But when calling the url I got redirected to /login and then I got an internal server error.
Solution: I also had to eliminate
'htaccess.RewriteBase' => '/nextcloud' inside the config and update
.htaccess with this:
sudo -u www-data php /var/www/nextcloud/occ maintenance:update:htaccess
Now it works. Anything else I missed?
Nope, that’s exactly the required steps, thanks for summing up!
Ok, thanks for confirming.
Still one problem:
Now I get the warning in nextcloud about some
/.well-known/* redirects. Worked before. What else do I have to do?
Tried to make a
.htaccess in my server’s root after General troubleshooting — Nextcloud latest Administration Manual latest documentation, but still the problem remains. (of course, actually, since the root is the /var/www/nextcloud folder)
I also tested the now-in-charge
.htaccess on https://htaccess.madewithlove.com/ and it looks fine, it redirects from
Now I try to view the logs on the server under
/var/log/apache2/, but they stay empty, although I put
LogLevel info rewrite:trace8 into my virtual host. Any hints on how to enable logging?
Ok, I cheched
journalctl -fu apache2 and found seemingly a problem:
Jul 08 09:44:57 homeserver apache2: [rewrite:trace1] [pid 4764:tid 281473399632256] mod_rewrite.c(486): [client ##.###.###.###:38832] ##.###.###.### - - [example.com/sid#ffffb2b2aab8][rid#ffffb01920a0/initial] [perdir /var/www/nextcloud/] pass through /var/www/nextcloud/nextcloud
Jul 08 09:44:57 homeserver apache2: [core:info] [pid 4764:tid 281473399632256] [client ##.###.###.###:38832] AH00128: File does not exist: /var/www/nextcloud/nextcloud/remote.php/dav
So, some rewrite seems to happen locally from the already “rewritten” document root.
Now, after eliminating
/etc/apache2/conf-enabled/dietpi-dav_redirect.conf the warning inside nextcloud are gone for
/.well-known/caldav. But still there for
/nextcloud from the
nodeinfo redirects inside
/etc/apache2/sites-enabled/dietpi-nextcloud.conf would be the obvious solution, but it isn’t.
I think it’s better to disable this config and let
.htaccess handle it:
systemctl reload apache2
This config is only required when Nextcloud is not the webroot.
/etc/apache2/sites-enabled/dietpi-nextcloud.conf. Would You consider changing this too? I tried it, but it has no seemingly effect on my problem. I lack the understanding, why parts of the whole redirection happen in
/etc/apache2/sites-enabled/dietpi-nextcloud.conf and in the
.htaccess, controlled by the
I’ll give up for now and live with the header redirect. Works ok most of the time, only in the rare case of configuring an app, I have to take a different URL.
Thanks anyway for helping. And if a real complete solution comes up, of course, I’m still interested.
Ah right, the
dietpi-nextcloud.conf is without effect now. You may add the directives globally instead.