Issue summary: Changing the nextcloud access URL from http://192.168.2.200/
to http://192.168.2.200/cloud
makes uploaded data inaccessible.
Docker Nextcloud tag: nextcloud:16.0.11-apache
Docker Nginx tag: nginx:1.19.0
Host Operating system and version: Ubuntu 20.04
Host Access URL: http://192.168.2.200/
When using nginx as a reverse proxy, and nextcloud with /
as the URL path (i.e. overwritewebroot' => '/'
), I can see all my data files that I’ve uploaded after I log in.
However, when I make modifications to the nginx.conf
file and the nextcloud/config/config.php
file to change the cloud’s URL path to /cloud
, I don’t see the data files I uploaded when I log in, and instead see the following error:
This directory is unavailable, please check the logs or contact the administrator
Here are my configuration files (I’ve added in comments what I’ve changed between the broken/working case).
nextcloud/config.php
:
<?php
$CONFIG = array (
'htaccess.RewriteBase' => '/',
'trusted_domains' =>
array (
0 => 'localhost',
1 => '192.168.2.200',
),
'datadirectory' => '/var/www/html/data',
'dbtype' => 'pgsql',
'version' => '16.0.11.1',
'overwrite.cli.url' => 'http://192.168.2.200',
'overwritewebroot' => '/cloud', # CHANGED FROM '/'
'trusted_proxies' =>
array (
0 => '172.0.0.0/8',
),
'forwarded_for_headers' =>
array (
0 => 'HTTP_FORWARDED_FOR',
),
...
...
);
nginx.conf
:
http {
include mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log combined;
sendfile on;
upstream cloud_server {
server cloud_app:80 fail_timeout=0;
}
server {
listen *:80;
client_max_body_size 10G;
server_name 192.168.2.200;
server_name_in_redirect off;
keepalive_timeout 5;
# ADDED THE FOLLOWING 2 LOCATIONS PER:
# https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/reverse_proxy_configuration.html#overwrite-parameters
location = /.well-known/carddav {
return 301 $scheme://$host:$server_port/cloud/remote.php/dav;
}
location = /.well-known/caldav {
return 301 $scheme://$host:$server_port/cloud/remote.php/dav;
}
location /cloud { # CHANGED FROM 'location /'
proxy_request_buffering off;
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-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_pass http://cloud_server/;
}
}
}