Directory unavailable after custom path for reverse proxy

Hi!

I’ve installed the snappy nextcloud (https://github.com/nextcloud/nextcloud-snap), changed its default HTTP port to 8081 (no interests on HTTPS for now) and configured the reverse proxy with Nginx as the following wiki: https://github.com/nextcloud/nextcloud-snap/wiki/Putting-the-snap-behind-a-reverse-proxy. It works perfectly until I try to configure the custom path ("/nextcloud"), and that’s when I get the “Directory unavailable” message.

On the log file, I got this:

{"reqId":"LIwbZZpG3z32bl5uhCsT","level":4,"time":"2018-09-12T03:38:26+00:00","remoteAddr":"127.0.0.1","user":"gabriel-milan","app":"webdav","method":"PROPFIND","url":"\/nextcloud\/remote.phpp\/webdav\/","message":"Exception: {\"Exception\":\"LogicException\",\"Message\":\"Requested uri (\\\/nextcloud\\\/remote.phpp\\\/webdav\\\/) is out of base uri (\\\/nextcloud\\\/remote.php\\\/webdav\\\/)\",\"Code\":0,\"Trace\":\"#0 \\\/snap\\\/nextcloud\\\/8267\\\/htdocs\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(1296): Sabre\\\\HTTP\\\\Request->getPath()\\n#1 \\\/snap\\\/nextcloud\\\/8267\\\/htdocs\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(474): Sabre\\\\DAV\\\\Server->checkPreconditions(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#2 \\\/snap\\\/nextcloud\\\/8267\\\/htdocs\\\/3rdparty\\\/sabre\\\/dav\\\/lib\\\/DAV\\\/Server.php(254): Sabre\\\\DAV\\\\Server->invokeMethod(Object(Sabre\\\\HTTP\\\\Request), Object(Sabre\\\\HTTP\\\\Response))\\n#3 \\\/snap\\\/nextcloud\\\/8267\\\/htdocs\\\/apps\\\/dav\\\/appinfo\\\/v1\\\/webdav.php(80): Sabre\\\\DAV\\\\Server->exec()\\n#4 \\\/snap\\\/nextcloud\\\/8267\\\/htdocs\\\/remote.php(164): require_once('\\\/snap\\\/nextcloud...')\\n#5 {main}\",\"File\":\"\\\/snap\\\/nextcloud\\\/8267\\\/htdocs\\\/3rdparty\\\/sabre\\\/http\\\/lib\\\/Request.php\",\"Line\":214}","userAgent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/69.0.3497.81 Safari\/537.36","version":"13.0.5.2"}

These are the versions of my stuff:

  • Nextcloud version: 13.0.5
  • Operating system and version: Debian Stretch
  • Apache version: 2.4
  • Nginx version: 1.10.3
  • PHP version: 7.1
  • MySQL version: 5.7
  • Redis version: 4.0

And this is my *.conf file for Nginx:

server {
        listen 80;
	listen [::]:80;
        server_name (my_host);

    	# Add headers to serve security related headers
    	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;

	location /nextcloud {
	    rewrite ^/nextcloud(.*) /$1 break;
	    proxy_pass_header 	Server;
	    proxy_set_header	Host		$host;
	    proxy_set_header	X-Real-IP	$remote_addr;
	    proxy_set_header	X-Forwarded-For	$proxy_add_x_forwarded_for;
	    proxy_set_header	X-Forwarded-Proto $scheme;
	    proxy_pass	http://127.0.0.1:8081;
	}

...

}

Can anyone please help me?