I have nextcloud running on https://cloud.museumsstrasse.at
but since we will use nextcloud primarily for opening data to the public I would like that this nextcloud root url leads to a public nextcloud folder directly, e.g. to use this one: https://cloud.museumsstrasse.at/s/Ytpcwos3o9o33kL
but so that the public would not need the url with the share sub-url but only type in https://cloud.museumsstrasse.at
where this public folder would be opened.
As for logging in and synchronizing with nextcloud I would then like to use another sub url such as this for example: https://cloud.museumsstrasse.at/internal
Is this possible and how?
My setup:
I got nextcloud running with docker on a Ubuntu 20.04
Server. Since other services are running on this server too, I set up a reverse proxy solution all with docker too including these images: nginx, jwilder/docker-gen:0.7.3, jrcs/letsencrypt-nginx-proxy-companion
which do the reverse proxy and also generate the config files for reverse proxy. The docker-compose.yml
for all this is this:
version: '3'
services:
service_nginx:
image: nginx:1.13.1
container_name: container_nginx
ports:
- "80:80"
- "443:443"
networks:
- network_nginx
volumes:
- ./volumes/nginx/conf:/etc/nginx/conf.d
- ./volumes/nginx/vhost:/etc/nginx/vhost.d
- ./volumes/nginx/html:/usr/share/nginx/html
- ./volumes/nginx-letsencrypt/certs:/etc/nginx/certs
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
service_nginx-dockergen:
image: jwilder/docker-gen:0.7.3
container_name: container_nginx-dockergen
depends_on:
- service_nginx
command: -notify-sighup container_nginx -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
networks:
- network_nginx
volumes:
- ./volumes/nginx/conf:/etc/nginx/conf.d
- ./volumes/nginx/vhost:/etc/nginx/vhost.d
- ./volumes/nginx/html:/usr/share/nginx/html
- ./volumes/nginx/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro
- ./volumes/nginx-letsencrypt/certs:/etc/nginx/certs
- /var/run/docker.sock:/tmp/docker.sock:ro
service_nginx-letsencrypt:
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: container_nginx-letsencrypt
depends_on:
- service_nginx
- service_nginx-dockergen
environment:
NGINX_PROXY_CONTAINER: container_nginx
NGINX_DOCKER_GEN_CONTAINER: container_nginx-dockergen
networks:
- network_nginx
volumes:
- ./volumes/nginx/conf:/etc/nginx/conf.d
- ./volumes/nginx/vhost:/etc/nginx/vhost.d
- ./volumes/nginx/html:/usr/share/nginx/html
- ./volumes/nginx-letsencrypt/certs:/etc/nginx/certs
- /var/run/docker.sock:/var/run/docker.sock:ro
service_nc_db:
image: mariadb
container_name: container_nc_db
volumes:
- ./volumes/nc_db:/var/lib/mysql
- /etc/localtime:/etc/localtime:ro
networks:
- network_nc_prod
environment:
- MYSQL_ROOT_PASSWORD=XXX
- MYSQL_PASSWORD=XXX
- MYSQL_DATABASE=XXX
- MYSQL_USER=XXX
restart: unless-stopped
service_nc:
image: nextcloud:latest
container_name: container_nc
depends_on:
- service_nc_db
- service_nginx
- service_nginx-dockergen
- service_nginx-letsencrypt
networks:
- network_nc_prod
- network_nginx
volumes:
- ./volumes/nc/html:/var/www/html
- ./volumes/nc/config:/var/www/html/config
- ./volumes/nc/custom_apps:/var/www/html/custom_apps
- ./volumes/nc/data:/var/www/html/data
- ./volumes/nc/themes:/var/www/html/themes
- /etc/localtime:/etc/localtime:ro
environment:
- VIRTUAL_HOST=cloud.museumsstrasse.at
- LETSENCRYPT_HOST=cloud.museumsstrasse.at
- LETSENCRYPT_EMAIL=XXX
restart: unless-stopped
networks:
network_ca_prod:
network_nc_prod:
network_nginx:
What I have tried so far is pushing the html code of nextcloud into a subfolder and fiddling around with settings such as overwritewebroot
or overwritehost
in config.php
and various experimentation on nginx reverse proxying, but it all failed so far.
What I have tried to follow were discussions such as these for example:
https://github.com/nextcloud/docker/issues/401
https://stackoverflow.com/questions/54716909/nextcloud-installation-in-subfolder-redirect-in-apache2
Nextcloud behind Ngnix reverse proxy in a subdir url
What does not work:
For example what doesn't work is if I add to config.php
these two lines:
'overwritehost' => 'cloud.museumsstrasse.at',
'overwritewebroot' => '/internal'
Then opening cloud.museumsstrasse.at
with the browser would get redirected to cloud.museumsstrasse.at/internal
but in the meantime the code in /var/www/html/internal/<nextcloud_code>
got deleted and overwritten with nextcloud code in /var/www/html/<nextcloud_code>
which I then can not open because the browser would redirect me to cloud.museumsstrasse.at/internal
again.
However even if something with overwritewebroot
were working, how could I avoid this redirection from cloud.museumsstrasse.at
to cloud.museumsstrasse.at/internal
? Because the former should be the public face and the latter our internal nextcloud side. Hence I want no redirection but two different urls for different purposes.
I assume if a pragmatic way would be to adapt nextcloud's docker image logic to point it to /var/www/html/internal/
and then adapt the this docker's internal apache to show cloud.museumsstrasse.at
while serving content from the public foldercloud.museumsstrasse.at/s/Ytpcwos3o9o33kL
? However I'm at a loss of how to do this...
Can someone help me here please?
Cheers, Stefan