[SOLVED] Some JS not loading, ignoring webserver (lighttpd) headers

Nextcloud version (eg, 12.0.2): 14.0.3.0
Operating system and version (eg, Ubuntu 17.04): Adélie Linux 1.0-beta1
Apache or nginx version (eg, Apache 2.4.25): lighttpd 1.4.52 (mod_webdav disabled)
PHP version (eg, 7.1): 7.2.11
Hardware: Raspberry Pi 3 Model B

The issue you are facing: Certain apps are not showing their UI, such as files_sharing. I click on the “Sharing” tab and normally there is a “Share link” checkbox and other options. Instead, all I see is a search box for federated cloud IDs. The app is enabled and straight from the app store. When I attempt to share using the Android app, I can get it to generate a share link and copy it to the Android clipboard, but it doesn’t display the URL in the UI.

When I open Firefox’s developer tools, I see that Nextcloud’s Content-Security-Policy headers are taking precedence over what I set in my webserver. Changing CSP headers in my webserver does not fix the behavior; Nextcloud seemingly ignores what is set and does what it wants, but it breaks apps that are officially supported.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Install NC 14.0.3
  2. configure lighttpd (see below for full config)
  3. install files_sharing
  4. navigate to Files and click on a Share icon
  5. See this:

The output of your Nextcloud log in Admin > Logging:

|Error|OCP\AppFramework\QueryException: Could not resolve OC\Core\Controller\WhatsNewController! Class OC\Updater\ChangesCheck does not exist|2018-12-04T19:04:28-0800|
|---|---|---|
|Error|include(): Failed opening '/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php' for inclusion (include_path='/usr/share/webapps/nextcloud/3rdparty/pear/archive_tar:/usr/share/webapps/nextcloud/3rdparty/pear/console_getopt:/usr/share/webapps/nextcloud/3rdparty/pear/pear-core-minimal/src:/usr/share/webapps/nextcloud/3rdparty/pear/pear_exception:/usr/share/webapps/nextcloud/apps:/var/lib/nextcloud/appstore') at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-04T19:04:28-0800|
|Error|include(/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php): failed to open stream: No such file or directory at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-04T19:04:28-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-04T19:03:32-0800|
|Error|OCP\AppFramework\QueryException: Could not resolve OC\Core\Controller\WhatsNewController! Class OC\Updater\ChangesCheck does not exist|2018-12-04T19:03:32-0800|
|Error|include(): Failed opening '/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php' for inclusion (include_path='/usr/share/webapps/nextcloud/3rdparty/pear/archive_tar:/usr/share/webapps/nextcloud/3rdparty/pear/console_getopt:/usr/share/webapps/nextcloud/3rdparty/pear/pear-core-minimal/src:/usr/share/webapps/nextcloud/3rdparty/pear/pear_exception:/usr/share/webapps/nextcloud/apps:/var/lib/nextcloud/appstore') at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-04T19:03:32-0800|
|Error|include(/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php): failed to open stream: No such file or directory at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-04T19:03:32-0800|
|Error|OCP\AppFramework\QueryException: Could not resolve OC\Core\Controller\WhatsNewController! Class OC\Updater\ChangesCheck does not exist|2018-12-04T17:25:48-0800|
|Error|include(): Failed opening '/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php' for inclusion (include_path='/usr/share/webapps/nextcloud/3rdparty/pear/archive_tar:/usr/share/webapps/nextcloud/3rdparty/pear/console_getopt:/usr/share/webapps/nextcloud/3rdparty/pear/pear-core-minimal/src:/usr/share/webapps/nextcloud/3rdparty/pear/pear_exception:/usr/share/webapps/nextcloud/apps:/var/lib/nextcloud/appstore') at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-04T17:25:48-0800|
|Error|include(/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php): failed to open stream: No such file or directory at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-04T17:25:48-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-04T17:21:42-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-04T14:36:15-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-04T14:16:15-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-04T12:25:44-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-04T12:24:15-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-03T23:39:38-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-03T23:22:38-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-03T21:50:51-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-03T21:50:49-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-03T08:41:01-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-03T08:25:01-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-03T07:48:00-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-03T06:31:00-0800|
|Error|OCP\AppFramework\QueryException: Could not resolve OC\Core\Controller\WhatsNewController! Class OC\Updater\ChangesCheck does not exist|2018-12-02T17:52:59-0800|
|Error|include(): Failed opening '/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php' for inclusion (include_path='/usr/share/webapps/nextcloud/3rdparty/pear/archive_tar:/usr/share/webapps/nextcloud/3rdparty/pear/console_getopt:/usr/share/webapps/nextcloud/3rdparty/pear/pear-core-minimal/src:/usr/share/webapps/nextcloud/3rdparty/pear/pear_exception:/usr/share/webapps/nextcloud/apps:/var/lib/nextcloud/appstore') at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-02T17:52:59-0800|
|Error|include(/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php): failed to open stream: No such file or directory at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-02T17:52:59-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-02T17:52:59-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-02T17:46:25-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-02T17:21:34-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-02T16:02:31-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-02T10:39:01-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-02T10:30:01-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-02T02:00:03-0800|
|Error|OCP\AppFramework\QueryException: Could not resolve OC\Core\Controller\WhatsNewController! Class OC\Updater\ChangesCheck does not exist|2018-12-02T02:00:02-0800|
|Error|include(): Failed opening '/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php' for inclusion (include_path='/usr/share/webapps/nextcloud/3rdparty/pear/archive_tar:/usr/share/webapps/nextcloud/3rdparty/pear/console_getopt:/usr/share/webapps/nextcloud/3rdparty/pear/pear-core-minimal/src:/usr/share/webapps/nextcloud/3rdparty/pear/pear_exception:/usr/share/webapps/nextcloud/apps:/var/lib/nextcloud/appstore') at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-02T02:00:02-0800|
|Error|include(/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php): failed to open stream: No such file or directory at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-02T02:00:02-0800|
|Error|OCP\AppFramework\QueryException: Could not resolve OC\Core\Controller\WhatsNewController! Class OC\Updater\ChangesCheck does not exist|2018-12-02T01:49:53-0800|
|Error|include(): Failed opening '/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php' for inclusion (include_path='/usr/share/webapps/nextcloud/3rdparty/pear/archive_tar:/usr/share/webapps/nextcloud/3rdparty/pear/console_getopt:/usr/share/webapps/nextcloud/3rdparty/pear/pear-core-minimal/src:/usr/share/webapps/nextcloud/3rdparty/pear/pear_exception:/usr/share/webapps/nextcloud/apps:/var/lib/nextcloud/appstore') at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-02T01:49:53-0800|
|Error|include(/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php): failed to open stream: No such file or directory at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-02T01:49:53-0800|
|Error|OCP\AppFramework\QueryException: Could not resolve OC\Core\Controller\WhatsNewController! Class OC\Updater\ChangesCheck does not exist|2018-12-02T01:47:59-0800|
|Error|include(): Failed opening '/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php' for inclusion (include_path='/usr/share/webapps/nextcloud/3rdparty/pear/archive_tar:/usr/share/webapps/nextcloud/3rdparty/pear/console_getopt:/usr/share/webapps/nextcloud/3rdparty/pear/pear-core-minimal/src:/usr/share/webapps/nextcloud/3rdparty/pear/pear_exception:/usr/share/webapps/nextcloud/apps:/var/lib/nextcloud/appstore') at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-02T01:47:59-0800|
|Error|include(/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php): failed to open stream: No such file or directory at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-02T01:47:59-0800|
|Error|OCP\AppFramework\QueryException: Could not resolve OC\Core\Controller\WhatsNewController! Class OC\Updater\ChangesCheck does not exist|2018-12-02T01:46:57-0800|
|Error|include(): Failed opening '/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php' for inclusion (include_path='/usr/share/webapps/nextcloud/3rdparty/pear/archive_tar:/usr/share/webapps/nextcloud/3rdparty/pear/console_getopt:/usr/share/webapps/nextcloud/3rdparty/pear/pear-core-minimal/src:/usr/share/webapps/nextcloud/3rdparty/pear/pear_exception:/usr/share/webapps/nextcloud/apps:/var/lib/nextcloud/appstore') at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-02T01:46:57-0800|
|Error|include(/usr/share/webapps/nextcloud/lib/composer/composer/../../../lib/private/Updater/ChangesCheck.php): failed to open stream: No such file or directory at /usr/share/webapps/nextcloud/lib/composer/composer/ClassLoader.php#444|2018-12-02T01:46:57-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-02T01:46:17-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-01T20:43:34-0800|
|Error|Zend OPcache can't be temporary enabled (it may be only disabled till the end of request) at Unknown#0|2018-12-01T20:34:04-0800|
|Error|imagecreatefromstring(): Data is not in a recognized format at /usr/share/webapps/nextcloud/lib/private/legacy/image.php#622|2018-12-01T15:17:25-0800|

The Zend errors don’t make any sense either, since opcache is enabled:

/etc/php/php-fpm.d/nextcloud.conf:

[global]
; Error log file
; Default Value: log/php-fpm.log
error_log = /var/log/nextcloud/php-fpm.log

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
log_level = warning

; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
emergency_restart_threshold = 10

; Interval of time used by emergency_restart_interval to determine when
; a graceful restart will be initiated.  This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
emergency_restart_interval = 1m

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
process_control_timeout = 10s


[nextcloud]
user = nextcloud
group = www-data
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket (the path is *not*
;                            relative to chroot!)
; Note: This value is mandatory.
listen = /run/nextcloud/fastcgi.sock

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
;                 mode is set to 0666
listen.mode  = 0660

; Choose how the process manager will control the number of child processes.
; Possible Values:
;   static   ... a fixed number of child processes.
;   dynamic  ... the number of child processes are set dynamically.
;   ondemand ... no children are created at startup; children will be forked
;                when new requests will connect.
; Note: This value is mandatory.
pm = ondemand

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; This value sets the limit on the number of simultaneous requests that will be
; served.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 5

; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
pm.process_idle_timeout = 120s

; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 500

; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page.
; Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set
pm.status_path =

; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set
ping.path = /ping

; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0

; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
; Note: the path is *not* relative to chroot.
;slowlog = /var/log/nextcloud/php-fpm.slow.log

; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; Default Value: no
;catch_workers_output = yes

; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
;   php_value/php_flag             - you can set classic ini defines which can
;                                    be overwritten from PHP call 'ini_set'.
;   php_admin_value/php_admin_flag - these directives won't be overwritten by
;                                     PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
;
; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.
;
; Note: path INI options can be relative and will be expanded with the prefix
; (pool, global or /usr/lib/php7.x)

; Allow HTTP file uploads.
php_admin_flag[file_uploads] = true

; Maximal size of a file that can be uploaded via web interface.
php_admin_value[memory_limit] = 512M
php_admin_value[post_max_size] = 200M
php_admin_value[upload_max_filesize] = 200M

; Where to store temporary files.
php_admin_value[session.save_path] = /var/tmp/nextcloud
php_admin_value[sys_temp_dir] = /var/tmp/nextcloud
php_admin_value[upload_tmp_dir] = /var/tmp/nextcloud

; Log errors to specified file.
php_admin_flag[log_errors] = on
php_admin_value[error_log] = /var/log/nextcloud/php.error.log

; OPcache error_log file name. Empty string assumes "stderr"
php_admin_value[opcache.error_log] = /var/log/nextcloud/php.error.log

; Output buffering is a mechanism for controlling how much output data
; (excluding headers and cookies) PHP should keep internally before pushing that
; data to the client. If your application's output exceeds this setting, PHP
; will send that data in chunks of roughly the size you specify.
; This must be disabled for ownCloud.
php_admin_flag[output_buffering] = false

; Overload(replace) single byte functions by mbstring functions.
; This must be disabled for ownCloud.
php_admin_flag[mbstring.func_overload] = false

; Never populate the $HTTP_RAW_POST_DATA variable.
; http://php.net/always-populate-raw-post-data
php_admin_value[always_populate_raw_post_data] = -1

; Disable certain functions for security reasons.
; http://php.net/disable-functions
php_admin_value[disable_functions] = exec,passthru,shell_exec,system,proc_open,curl_multi_exec,show_source

; Set recommended settings for OpCache.
; https://docs.nextcloud.com/server/13/admin_manual/configuration_server/server_tuning.html#enable-php-opcache
php_admin_flag[opcache.enable] = true
php_admin_flag[opcache.enable_cli] = true
php_admin_flag[opcache.save_comments] = true
php_admin_value[opcache.interned_strings_buffer] = 8
php_admin_value[opcache.max_accelerated_files] = 10000
php_admin_value[opcache.memory_consumption] = 512
php_admin_value[opcache.revalidate_freq] = 1

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'datadirectory' => '/var/lib/nextcloud/data',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/usr/share/webapps/nextcloud/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/lib/nextcloud/appstore',
      'url' => '/appstore',
      'writable' => true,
    ),
  ),
  'updatechecker' => false,
  'check_for_working_htaccess' => false,
  'htaccess.IgnoreFrontController' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'installed' => true,
  'instanceid' => 'ocoduo86ciwx',
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' => 
  array (
    0 => 'files.zlg.space',
  ),
  'dbtype' => 'pgsql',
  'version' => '14.0.3.0',
  'overwrite.cli.url' => 'https://files.zlg.space',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost:5432',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => 'REDACTED',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_from_address' => 'REDACTED',
  'mail_domain' => 'REDACTED',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'REDACTED',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'REDACTED',
  'mail_smtppassword' => 'REDACTED',
  'maintenance' => false,
  'data-fingerprint' => 'a75e4d3ac820643941189b36cd5a2b7b',
);

The output of your Apache/nginx/system log in /var/log/____:

(nothing related to Nextcloud is in the error log; everything works as it should on the backend)

PASTE HERE

lighttpd config:

# Modified from Adélie's default config (see lighttpd.conf.orig)

var.basedir          = "/srv/www"
var.logdir           = "/var/log/lighttpd"
var.statedir         = "/var/lib/lighttpd"

# NOTE: the order of modules is important.
server.modules = (
	"mod_rewrite",
	"mod_redirect",
	"mod_alias",
	"mod_access",
	#"mod_cml",
	#"mod_trigger_b4_dl",
	#"mod_auth",
	#"mod_status",
	"mod_setenv",
	#"mod_proxy",
	#"mod_simple_vhost",
	#"mod_evhost",
	#"mod_userdir",
	"mod_compress",
	#"mod_ssi",
	#"mod_usertrack",
	"mod_expire",
	#"mod_secdownload",
	#"mod_rrdtool",
	#"mod_webdav",
	"mod_accesslog",
	"mod_openssl",
	"mod_dirlisting",
	"mod_cgi"
)

include "mime-types.conf"
include "mod_fastcgi.conf"

server.username            = "lighttpd"
server.groupname           = "www-data"
server.document-root       = var.basedir + "/html"

accesslog.filename         = var.logdir + "/access.log"
server.breakagelog         = var.logdir  + "/breakage.log"
server.errorlog            = var.logdir  + "/error.log"
server.errorlog-use-syslog = "enable"

server.event-handler       = "linux-sysepoll"
server.follow-symlink      = "enable"
server.indexfiles          = ("index.xhtml", "index.html", "index.htm", "default.htm")
server.pid-file            = "/run/lighttpd.pid"
server.stat-cache-engine   = "fam"
server.upload-dirs         = ("/var/tmp/lighttpd")

static-file.exclude-extensions = (".py", ".php", ".pl", ".cgi", ".fcgi")

url.access-deny = ("~", ".inc", ".sw?")

# force HTTPS
$SERVER["socket"] == ":80" {
	url.redirect = ( "" => "https://${url.authority}${url.path}${qsa}" )
}

# SSL
$SERVER["socket"] == ":443" {
	ssl.engine                       = "enable"
	ssl.honor-cipher-order           = "enable"
	ssl.disable-client-renegotiation = "enable"
	# pemfile is cert+privkey, ca-file is the full chain in one file
	ssl.pemfile = "/etc/letsencrypt/live/zlg.space/combined.pem"
	ssl.ca-file = "/etc/letsencrypt/live/zlg.space/fullchain.pem"
	ssl.ec-curve = "secp384r1"
	setenv.add-environment = (
		"HTTPS" => "on"
	)
	# See https://cipherli.st for up-to-date suggestions
	ssl.use-sslv2   = "disable"
	ssl.use-sslv3   = "disable"
	ssl.cipher-list = "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"
	setenv.add-response-header  = (
		"Strict-Transport-Security" => "max-age=15768000;", # HSTS(15768000 seconds = 6 months)
		#"X-Content-Type-Options" => "nosniff"
	)
}

# compression
compress.cache-dir	= var.statedir + "/cache/compress"
compress.filetype	= ("text/plain", "text/html")

######## mod_proxy config ########
# See proxy.txt in lighttpd-doc package for more info.
# proxy.server               = ( ".php" =>
#                               ( "localhost" =>
#                                 (
#                                   "host" => "192.168.0.101",
#                                   "port" => 80
#                                 )
#                               )
#                             )
# }}}

$HTTP["host"] == "pkgs.zlg.space" { include "pkgs.zlg.space.conf" }
$HTTP["host"] == "wiki.zlg.space" { include "wiki.zlg.space.conf" }
$HTTP["host"] == "git.zlg.space"  { include "git.zlg.space.conf" }
$HTTP["host"] == "files.zlg.space"  { include "files.zlg.space.conf" }

# vim: set ft=conf foldmethod=marker et :

NC-specific config:

server.name = "files.zlg.space"
server.document-root = "/usr/share/webapps/nextcloud"

fastcgi.server = (
	".php" => (
		"localhost" => ( "socket" => "/run/nextcloud/fastcgi.sock" )
	)
)

url.redirect += (
	"^/.well-known/caldav" => "/remote.php/dav",
	"^/.well-known/carddav" => "/remote.php/dav"
)

$HTTP["url"] =~ "^/(\.|autotest|occ|issue|indie|db_|console)" {
	url.access-deny = ("")
}

$HTTP["url"] =~ "^/(?:build|tests|config|lib|3rdparty|templates|data)" {
	url.access-deny = ("")
}

url.rewrite-once += (
	"^/((?:apps|appstore)/.*\.php.*)" => "/index.php/$1"
)

url.rewrite-if-not-file += (
	"^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater|ocs-provider/.+)\.php/.*" => "",
	"^/(.*)$" => "/index.php/$1"
)


$HTTP["url"] =~ "\.(?:css|js|woff|svg|gif)$" {
	setenv.add-response-header = (
		"Cache-Control" => "public, max-age=15778463",
		"X-Content-Type-Options" => "nosniff",
		"X-XSS-Protection" => "1; mode=block",
		"X-Robots-Tag" => "none",
		"X-Download-Options" => "noopen",
		"X-Permitted-Cross-Domain-Policies" => "none",
		"Referrer-Policy" => "no-referrer",
		"Content-Security-Policy" => "default-src 'self' *.zlg.space; data: 'unsafe-inline' 'unsafe-eval' *.zlg.space;",
	)
}

Note the final header sent; that header should allow all scripts to get through (for testing), but NC behaves the same way with and without said header.

Likewise, the Admin Overview page says my webserver is not sending the Referrer-Policy header, but as we clearly see above, it is being sent.

Here’s a more detailed look of the computed headers once a Files page is loaded:

No other applications on my webserver (DokuWiki, cgit) are giving me this kind of trouble. They accept the server’s headers and work with them. What can I do to make Nextcloud cooperate? This looks like a bug somewhere in NC’s apps. Contacts, Calendar, Gallery, Activity, Checksum, etc all work. It’s files_sharing that seems to be having issues.

I understand that lighttpd isn’t a server that many NC devs are familiar with. The issues NC used to have on lighttpd were related to mod_webdav, which (a) my server has not enabled, and (b) has been fixed to match all relevant functionality needed from it, for those who use it.

If you made it this far, thanks for reading. I enjoy NC and would like to integrate more with it, but refusal to accept the server’s headers is baffling. It’s not very useful to me if I can’t share files.

Here’s another picture since I was limited to 2 in the OP:

To follow up, I sought help in the #nextcloud channel on Freenode. We managed to narrow it down to my adblocker (uBlock Origin) and some specific lists (Fanboy’s Social Blocking and/or Fanboy’s Annoyance lists).

By whitelisting my NC instance in uBlock Origin, the “Share link” checkbox reappeared and everything works fine again!

Shout out to @Lartza for the assistance! I’ll edit the first post to mark it solved.