Closed ghost closed 3 years ago
I think this would imply a great security risk as the include directive of ngnix is not bound to any particular commands like .htaccess is. You basically create a server config file, which can be changed by the user running the nextcloud php process. As an admin, I would not allow this.
Please note; nginx is NOT officially supported by Nextcloud. Only Apache is officially supported, nginx is only community maintained.
I agree, this would be a potential security risk. If that were used on say shared hosting, a user could crash the entire server by entering something incorrectly. Nginx configs, unlike apache, must be modified ONLY by server administrators and should never be available to users.
if it really weakens security, of course, it should not be done in this way. Perhaps someone might have another Idea to make it easier.
How to use GitHub
provide a Nginx V-Host File in the root Directory of a Nextcloud Installation like a .htaccess File
With each update, the V-Host configuration in the Nextcloud documentation changes. As you can see here when you compare the two docs. there have been minor changes that can be seen here. For example the .well-known location. https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html https://docs.nextcloud.com/server/stable/admin_manual/installation/nginx.html
Unlike the Apache web server, where you have the .htaccess file, which is included as standard with every Nextcloud installation and can also be updated via a normal Nextcloud update, Nginx does not have this option. However, the problem can be solved by adding a .nginx-config file to every Nextcloud installation.
An implementation could look like this:
1: your regular V-Host File /etc/nginx/sites-enabled/nextcloud.conf could look like this:
As you can see, the Nextcloud related configurations were removed from this config file. The Nextcloud-related configurations are located in the new .nginx-config file. A new include statement has been added at the end. This statement refers to the new .nginx-config file that would be added to the root directory of your Nextcloud installation.
2: the additional Nextcloud provided V-Host File /var/www/nextcloud/.nginx-config could look like this:
The advantage of this implementation is that the Nginx configuration is always up to date, similar to an Apache web server. Since the .nginx-config file can be updated like the .htaaccess file.
to load the new configuration after an update might have to reload/restart Nginx because the configuration is only read once when the webserver is started. Here you could use a daemon/watchdog to automatically reload/restart nginx after an update as mentioned here. https://github.com/nextcloud/notify_push/pull/48
so and why do you need it now? 1: to give beginners an easy way to use a secure web server configuration. Not every change in the dokumentation can be recognized as such at first glance and changes are nowhere mentioned clearly enough. 2: to fix security misconfigurations. https://nextcloud.com/blog/urgent-security-issue-in-nginx-php-fpm/ 3: Convenience for a significant proportion of Nextcloud users who usually get by with the standard configuration. 4: less or no manual web server configuration changes are necessary anymore because they are applied to a large extent after a Nextcloud update with the .nginx-config file.