I have nextcloud set up using the nixos service and I can access it via localhost
on my host computer but I cannot access it by my host’s internal IP address (even from my host). I’m new to this stuff but I thought localhost
was an aliases for the computer’s internal IP so how could one work but not the other? It’s also worth mentioning I have tried hosting other sites that I can access from other devices on the network through the internal IP so confusion about what address to use doesn’t seem to be the problem.
I have a few questions but the main goal is accesing nextcloud from another device on my local network.
Following the wiki, I can get nextcloud running on localhost:8080
with:
services.nextcloud = {
enable = true;
package = pkgs.nextcloud24;
hostName = "localhost";
config.adminpassFile = "${pkgs.writeText "adminpass" "test123"}";
};
services.nginx = {
enable = true;
virtualHosts."localhost" = {
listen = [{
addr = "127.0.0.1";
port = 8080;
}];
};
};
I’ve tried messing with hostName
to use the internal IP instead. (To make things a little more convoluted, my router’s DNS is set to nextdns, I have a rewrite rule there to send nextcloud.home → internal IP). Not knowing what I’m doing with nginx
I decided to press on blindly. So I changed hostName
to "nextcloud.home"
and altered nginx
config to:
services.nginx = {
enable = true;
virtualHosts."nextcloud.home:8080" = {
locations."/".proxyPass = "http://127.0.0.1";
};
};
At this point I can get to nextcloud on the host computer with the url nextcloud.home
but this still only works on the host computer. Which leads to a few questions:
- If
nextcloud.home
is being rewritten to the internal IP of the host across the whole network, why is this only working on one computer? All devices should be being sent to the same place. The only reason I could think of is ifnginx
is sending all devices to their own127.0.0.1
but that doesn’t seem to make sense and replacing the value ofproxyPass
with the internal IP of the host still has the same problem (can access from the host only). - Why does this only work with the port on the virtual host name and not on the proxy pass address? This seems backwards, doesn’t this say it’s passing “nextcloud.home:8080” → “http://127.0.0.1” yet it seems to be passing “nextcloud.home” → “http://127.0.0.1:8080” being that I can access it via
nextcloud.home
but notnextcloud.home:8080
. Since I’m hosting different sites, I don’t want the internal IP address to go straight to port 8080 I would rather have<internal IP>:8080
go to nextcloud.
It would be really nice if I could have multiple rewrite rules for my nextdns that all went to internal IP then said “nextcloud.home” → “http://127.0.0.1:8080”, “jellyfin.home” → “http://127.0.0.1:8096”, etc but with how it’s set up now, if I go to “jellyfin.home” it takes me to a nextcloud warning page saying I’m accessing nextcloud through an untrusted domain. Is there anyway to set this up without registering any domains? The sites are only intended to be accessed locally.