NC together with docker is really great and simple to install. Thank you all for that great job!
But as usual there are always some people that do want a little more.
NC is running in a VirtualBox-VM. NC is accessible within the VM and from the host by using the IP of the VM. This is 192.168.178.38:8080 for example.
Now I want to access NC by a name, not by it’s IP: nc.gerd.lan instead of 192.168.178.38:8080.
One reason for this is, that I want to install additional services using port 8080 as well. Theoretical I could map the ports to 8081, 8082… But that’s really theoretical.
Here I’m open to do anything within the VM, i.e. DNS, Webserver, whatever. But I’m interested in doing a minimum on all the other devices that should access NC like other hosts, mobile …
I really tried a lot and was partially successful related to access within the VM. But I fail from outside the VM.
Any hint or link is really welcome. There must be thousands of installations of this style, with or without docker, but I didn’t find a cookbook.
A down and dirty way for just the local lan is to add the VM to your /etc/hosts file.
That should do it locally on your internal network. You will have to add it to all the computers hosts files on the lan though.
This is a great question. I just deployed it to VirtualBox as well, and noticed that it doesn’t actually register an IP from the gateway, I can log into the router and it doesn’t see NC, despite it having a reachable IP. I’m not sure how VirtualBox bridging truly works, but it couldn’t reach DHCP so I had to set a manual IP. This must be due to being unable to reach DHCP and DNS services from my router itself.
I also spun up a Windows machine today, through VirtualBox with the same network configuration, and it reached my gateway, grabbed a DHCP IP, and it’s DNS name is registered in the router, so I can reach it via DNS. There must be either a NextCloud or Linux configuration blocking or interfering with it reaching the gateway.
If I add my router as a secondary DNS server, it registers in as a client in the router, but with the hostname of my host machine. I don’t know Linux very well, so it’ll be a journey to figure out how to get it to register the proper hostname like my Windows VM.
Yeah I’m stuck here. I’ve added the hostname to additional IPs (loopback and current network IP), changed DNS order, but nothing registers it properly. It always shows as the host.
I went into the router and found a DNS host entry section. Added it there, so all devices on the network will find it. I was never able to get it to register properly. But a good start for you would be to go to webmin and add your router as a secondary DNS server there. Also, if you can get it to register an IP from DHCP, that would probably be best. Once it obtains a DHCP address, it should register hostname information with your DHCP server.
This is a solution if I have only ONE web service. Then I can access it with http://nc.gerd.lan:8080.
But what if I have more than one?
In principle you can’t use the same port for multiple services that are running on the same server / IP. But if we strictley talking about web services, there are ways to make it possible…
If all services are served by the same web server e.g. apache or nginx you could use seperate VirtualHosts for each service and name them
If these services / apps have their own web server bundeld like e.g. the Nextcloud docker container, you could setup a sperate web server on the host system or on another server with multiple VirtualHosts in a reverse proxy configuration. The reverse proxy then forwards the requests to the web servers of the respective services / apps.
In both cases you would also no longer have to use port 8080 or whatever port the respective app uses. Instead you could access everything via the reverse proxy on port 80.
@bb77: I think this is exactly the solution. I played with appache and I played with dnsmasq. But I never played with both at the same time. And this idea came up in my mind this night.
I have to figure out how to set up apache, but I hope I will handle it.
@ALL: Thank’s a lot. At the end this post did help to find the solution for a task that created headache for months
I‘m really sorry. It is still open. Apache is not the solution. Apache is part of the NC-container. This is the reason why it is possible to access the NC-Web-Side, the NC user interface.
An entry in etc/ hosts inside the VM is limited on the usage inside the VM only.
I think a solution could be to make any docker network, normally starting with ‚172. …‘, accessible outside the VM. Then I can setup an additional DNS inside the VM and use this outside the VM.
I also tried to create a docker network based on macvlan. This should bring the container into the network of the VM and so into the network of the router (192.168.178.xxx).
But all I did up to now fails…………
So still any help appreciated!
Thats why you need a reverse proxy in front of it, when you want to serve more than one service using Docker on the same ip and port.
Why? Don’t do that! You already can reach the service via IP and Port. If you want to use port 80 and a nice URL instead of ip_aderess:8080 you have to setup a reverse proxy. The reverse proxy then recieves the requests on port 80 and forwards it to your Docker container on port 8080.
Additionally you have to make sure that the choosen DNS name (nc.gerd.lan) resolves to the ip of the reverse proxy. This can be done either on your router (if it supports DNS overrides), on a seperate DNS-server or in the hosts files of your client devices. No matter which method you use, at the end of the day nc.gerd.lan must point to to the IP of the server, where the reverse proxy is installed. This can be the same server on which Nextcloud is running, if you decide to install the reverse proxy there.
So long story short…
There are two independed things necesasarry in order for it to work the way you want it:
A reverse proxy, in order to make Nexcloud Docker and any further services available on port 80, so you don’t have to specify a specific port
Working DNS resolution for each service, in order to use names instread of IP addresses.
Oh you weren’t actually trying to solve the DNS issue, just apply a bandaid. That makes more sense.