Nextcloud version: 15.0
Operating system and version: Debian 9
Apache or nginx version: NGinX 1.14.1 (with TLS 1.3 patched in)
PHP version: 7.2-fpm
The issue you are facing:
In order to use the new backup-function of Threema I created a directory for the backups and shared a password-protected link. For using the link-URL I had to fiddle with the URL - instructions are given here (german only, sorry).
Now whenever I invoke the URL
https://<Link-ID>:<$password>@mein.server.fnord/public.php/webdav/
I get the NC error screen telling me the access was unauthorized.
An other user on that forum thread reported the same behaviour on a NC 14.04 running on Apache + PHP-fpm - eveything else seemed similar. Getting rid of special chars in the password didn’t help.
Something similar has been reported regarding Apache + PHP-fpm and the problem was that the username:password part wasn’t passed on to PHP. Can’t find the solution right now, but it was solved by optimising the Apache RewriteConditions.
Maybe someone found a solution for NginX + PHP-fpm?
Steps to replicate it:
- share directory with a link, copy URL (https://cloud.example.com/s/
- try to invoke an URL like https://<linkID>:<password>@cloud.example.com/public.php/webdav/
- either get asked for a password or aget an error screen complaining about unauthorized access
Here’s my NGinX-config for the subdomain, basically copied from the NC manual about two years ago (NC 12? NC 13?)
upstream php-handler {
server unix:/var/run/php/php7.2-fpm.sock;
}
server {
listen 80;
server_name cloud.example.com;
# enforce https
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name cloud.example.org;
ssl_certificate /etc/nginx/ssl/example.com/fullchain;
ssl_certificate_key /etc/nginx/ssl/example.com/key;
# include ssl settings from snippet
include /etc/nginx/snippets/ssl-settings.conf;
access_log /var/log/nginx/cloud.example.com-access.log anonymized;
error_log /var/log/nginx/cloud.example.com-error.log info;
# include certbot-snippet
include /etc/nginx/snippets/certbot.conf;
# Add headers to serve security related headers
# Before enabling Strict-Transport-Security headers please read into this
# topic first.
# add_header Strict-Transport-Security "max-age=15768000;
# includeSubDomains; preload;";
#
# WARNING: Only add the preload option once you read about
# the consequences in https://hstspreload.org/. This option
# will add the domain to a hardcoded list that is shipped
# in all major browsers and getting removed from this list
# could take several months.
# add_header X-Content-Type-Options nosniff;
# add_header X-XSS-Protection "1; mode=block";
# add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
more_clear_headers 'X-Frame-Options';
add_header X-Frame-Options "SAMEORIGIN";
add_header Content-Security-Policy "frame-ancestors office.example.com cloud.example.com";
add_header Referrer-Policy "no-referrer-when-downgrade";
# Path to the root of your installation
root /var/www/nextcloud/;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# The following 2 rules are only needed for the user_webfinger app.
# Uncomment it if you're planning to use this app.
#rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
#rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json
# last;
location = /.well-known/carddav {
return 301 $scheme://$host/remote.php/dav;
}
location = /.well-known/caldav {
return 301 $scheme://$host/remote.php/dav;
}
# set max upload size
client_max_body_size 4100M;
fastcgi_buffers 64 4K;
fastcgi_read_timeout 600;
# Enable gzip but do not remove ETag headers
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
# Uncomment if your server is build with the ngx_pagespeed module
# This module is currently not supported.
#pagespeed off;
location / {
rewrite ^ /index.php$uri;
}
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
deny all;
}
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
deny all;
}
location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
#Avoid sending the security headers twice
fastcgi_param modHeadersAvailable true;
fastcgi_param front_controller_active true;
fastcgi_pass php-handler;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
}
location ~ ^/(?:updater|ocs-provider)(?:$|/) {
try_files $uri/ =404;
index index.php;
}
# Adding the cache control header for js and css files
# Make sure it is BELOW the PHP block
location ~ \.(?:css|js|woff|svg|gif)$ {
try_files $uri /index.php$uri$is_args$args;
add_header Cache-Control "public, max-age=15778463";
# Add headers to serve security related headers (It is intended to
# have those duplicated to the ones above)
# Before enabling Strict-Transport-Security headers please read into
# this topic first.
# add_header Strict-Transport-Security "max-age=15768000;
# includeSubDomains; preload;";
#
# WARNING: Only add the preload option once you read about
# the consequences in https://hstspreload.org/. This option
# will add the domain to a hardcoded list that is shipped
# in all major browsers and getting removed from this list
# could take several months.
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
# Optional: Don't log access to assets
access_log off;
}
location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
try_files $uri /index.php$uri$is_args$args;
# Optional: Don't log access to other assets
access_log off;
}
}
The output of your config.php file in /path/to/nextcloud
(make sure you remove any identifiable information!):
$CONFIG = array (
'instanceid' => 'ocb1q5swl3an',
'passwordsalt' => 'whatever',
'secret' => 'completelygarbledgibberishresemblinapassword',
'trusted_domains' =>
array (
0 => 'cloud.example.com',
1 => 'cardhu',
2 => '192.168.1.42',
),
'datadirectory' => '/mnt/RAID/nextcloud-data',
'overwrite.cli.url' => 'https://cloud.example.com',
'dbtype' => 'mysql',
'version' => '15.0.0.10',
'dbname' => 'nextcloud',
'dbhost' => 'localhost',
'dbtableprefix' => 'oc_',
'dbuser' => 'nextcloud',
'dbpassword' => 'secretpass',
'logtimezone' => 'UTC',
'installed' => true,
'memcache.local' => '\\OC\\Memcache\\APCu',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'redis' =>
array (
'host' => '/var/run/redis/redis-server.sock',
'port' => 0,
'timeout' => 0.0,
),
'updater.release.channel' => 'beta',
'mail_smtpmode' => 'smtp',
'mail_from_address' => 'nextcloud',
'mail_domain' => 'example.com',
'mail_smtphost' => 'example.com',
'mail_smtpport' => '587',
'mail_smtpauthtype' => 'LOGIN',
'theme' => '',
'loglevel' => 0,
'maintenance' => false,
'appstore.experimental.enabled' => true,
// 'appstoreenabled' => true,
// 'appstoreurl' => "https://api.nextcloud.com/v1",
'debug' => true,
'session_lifetime' => 86400,
'session_keepalive' => true,
'mail_smtpauth' => 1,
'mail_smtpsecure' => 'tls',
'mail_smtpname' => 'mailuser',
'mail_smtppassword' => 'secretpass',
'data-fingerprint' => '0705c71a39312c40f63b443be7c2ea90',
);
The output of your Apache/nginx/system log in /var/log/____
:
{"reqId":"fRXNAWxGNSJHxL0vmjiL","level":0,"time":"2018-12-17T22:31:09+00:00","remoteAddr":"91.59.53.226","user":"--","app":"webdav","method":"GET","url":"\/public.php\/webdav\/","message":{"Exception":"Sabre\\DAV\\Exception\\NotAuthenticated","Message":"No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured","Code":0,"Trace":[{"function":"beforeMethod","class":"Sabre\\DAV\\Auth\\Plugin","type":"->","args":[{"absoluteUrl":"https:\/\/mein.server.fnord\/public.php\/webdav\/","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"\/var\/www\/nextcloud\/3rdparty\/sabre\/event\/lib\/EventEmitterTrait.php","line":105,"function":"call_user_func_array","args":[[{"autoRequireLogin":true,"__class__":"Sabre\\DAV\\Auth\\Plugin"},"beforeMethod"],[{"absoluteUrl":"https:\/\/mein.server.fnord\/public.php\/webdav\/","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"\/var\/www\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php","line":466,"function":"emit","class":"Sabre\\Event\\EventEmitter","type":"->","args":["beforeMethod",[{"absoluteUrl":"https:\/\/mein.server.fnord\/public.php\/webdav\/","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]]},{"file":"\/var\/www\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Server.php","line":254,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->","args":[{"absoluteUrl":"https:\/\/mein.server.fnord\/public.php\/webdav\/","__class__":"Sabre\\HTTP\\Request"},{"__class__":"Sabre\\HTTP\\Response"}]},{"file":"\/var\/www\/nextcloud\/apps\/dav\/appinfo\/v1\/publicwebdav.php","line":107,"function":"exec","class":"Sabre\\DAV\\Server","type":"->","args":[]},{"file":"\/var\/www\/nextcloud\/public.php","line":78,"args":["\/var\/www\/nextcloud\/apps\/dav\/appinfo\/v1\/publicwebdav.php"],"function":"require_once"}],"File":"\/var\/www\/nextcloud\/3rdparty\/sabre\/dav\/lib\/DAV\/Auth\/Plugin.php","Line":168,"CustomMessage":"--"},"userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Ubuntu Chromium\/71.0.3578.80 Chrome\/71.0.3578.80 Safari\/537.36","version":"15.0.0.10"}