I found one valid config but it may not work properly in your environments because my nextcloud server deployment is a little speicial.
My Nextcloud version is v24.0.6 and is deployed in docker (linuxserver/nextcloud:lastest). It’s behind another nginx reverse proxy web server running in docker on physic Unraid PC and it needs port forward as the PC is in a NAT network.
The network route to nextcloud container is like:
Internet IP:10000 → Unraid nginx container:18443 → reverse proxy to Unraid:9000 → port forward locally to nextcloud container:80
Here’s the nginx.conf:
location = /.well-known/host-meta {
return 301 $scheme://$http_hostpublic.php?service=host-meta;
}
location = /.well-known/host-meta.json {
return 301 $scheme://$http_host/public.php?service=host-meta-json;
}
location = /.well-known/carddav {
return 301 $scheme://$http_host/remote.php/dav;
}
location = /.well-known/caldav {
return 301 $scheme://$http_host/remote.php/dav;
}
location = /.well-known/webfinger{
return 301 $scheme://$http_host/index.php/.well-known/webfinger;
}
location = /.well-known/nodeinfo{
return 301 $scheme://$http_host/index.php/.well-known/nodeinfo;
}
After adding things above, remember to clean or refresh the web browser cache.
PS:
Because of the special network environment, I added something unusual to the reverse proxy part. (proxy_set_header)
location / {
proxy_pass http://192.168.9.10:9000/;
proxy_set_header Host $host:10000;
}