Home Explore Blog Models CI



nixpkgs

4th chunk of `nixos/modules/services/web-apps/nextcloud.md`
a747bbf101367611bdd9e3747113719c6bc94a0ad4bf87cb0000000100000b41
    `override.config.php`.

    One option to work around this is to turn off the cache by setting
    the cache size to zero:

    ```nix
    { services.nextcloud.phpOptions."realpath_cache_size" = "0"; }
    ```

  - **Empty Files on chunked uploads**

    Due to a limitation of PHP-FPM, Nextcloud is unable to handle chunked
    uploads. See upstream issue
    [nextcloud/server#7995](https://github.com/nextcloud/server/issues/7995)
    for details.

    A workaround is to disable chunked uploads with
    {option}`nextcloud.nginx.enableFastcgiRequestBuffering`.

## Using an alternative webserver as reverse-proxy (e.g. `httpd`) {#module-services-nextcloud-httpd}

By default, `nginx` is used as reverse-proxy for `nextcloud`.
However, it's possible to use e.g. `httpd` by explicitly disabling
`nginx` using [](#opt-services.nginx.enable) and fixing the
settings `listen.owner` & `listen.group` in the
[corresponding `phpfpm` pool](#opt-services.phpfpm.pools).

An exemplary configuration may look like this:
```nix
{
  config,
  lib,
  pkgs,
  ...
}:
{
  services.nginx.enable = false;
  services.nextcloud = {
    enable = true;
    hostName = "localhost";

    # further, required options
  };
  services.phpfpm.pools.nextcloud.settings = {
    "listen.owner" = config.services.httpd.user;
    "listen.group" = config.services.httpd.group;
  };
  services.httpd = {
    enable = true;
    adminAddr = "webmaster@localhost";
    extraModules = [ "proxy_fcgi" ];
    virtualHosts."localhost" = {
      documentRoot = config.services.nextcloud.package;
      extraConfig = ''
        <Directory "${config.services.nextcloud.package}">
          <FilesMatch "\.php$">
            <If "-f %{REQUEST_FILENAME}">
              SetHandler "proxy:unix:${config.services.phpfpm.pools.nextcloud.socket}|fcgi://localhost/"
            </If>
          </FilesMatch>
          <IfModule mod_rewrite.c>
            RewriteEngine On
            RewriteBase /
            RewriteRule ^index\.php$ - [L]
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule . /index.php [L]
          </IfModule>
          DirectoryIndex index.php
          Require all granted
          Options +FollowSymLinks
        </Directory>
      '';
    };
  };
}
```

## Installing Apps and PHP extensions {#installing-apps-php-extensions-nextcloud}

Nextcloud apps are installed statefully through the web interface.
Some apps may require extra PHP extensions to be installed.
This can be configured with the [](#opt-services.nextcloud.phpExtraExtensions) setting.

Alternatively, extra apps can also be declared with the [](#opt-services.nextcloud.extraApps) setting.
When using this setting, apps can no longer be managed statefully because this can lead to Nextcloud updating apps
that are managed by Nix:

```nix
{ config, pkgs, ... }:

Title: Nextcloud Configuration: PHP Cache, Chunked Uploads, Reverse Proxies, and App/Extension Management
Summary
This section covers several advanced Nextcloud configuration and troubleshooting topics. It provides a workaround for 'No such file or directory' errors by disabling PHP's `realpath_cache_size` to 0 and addresses 'Empty Files on chunked uploads' by disabling chunked uploads using `nextcloud.nginx.enableFastcgiRequestBuffering`. The document then details how to use an alternative webserver like Apache (`httpd`) as a reverse proxy instead of Nginx, offering a comprehensive Nix configuration example that includes disabling Nginx, configuring PHP-FPM pool settings, and setting up Apache virtual hosts with `proxy_fcgi` and rewrite rules. Finally, it explains how to install Nextcloud apps and PHP extensions, distinguishing between stateful installation via the web interface and declarative management using `phpExtraExtensions` and `extraApps` in Nix, noting that using `extraApps` prevents stateful web interface management.