How setup a local NC server so that it’s accessible by the local IP-address itself from inside a home network

Nextcloud version (eg, 20.0.5): 29.0.0.19
Operating system and version (eg, Ubuntu 20.04): Debian 12
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.59 (Debian)
PHP version (eg, 7.4): 8.2.18 (cli) (built: Apr 11 2024 22:07:45) (NTS)

I’m running a NC instance/server on a Proxmox Debian 12 VM with NGINX reverse proxy, on my LAN (Machine is a Dell Optiplex Desktop). NC works great when accessing it from the internet, via my (redacted) domain name xxxxx.com, but when I try to access it from my LAN by typing the local IP address (192.168.1.40) of my NC server in a browser, I get the default Apache Landing page:

My motivation for local access to NC is to be able to download NC files from my server to a home PC (on the same LAN) at my network speed (close to 1Gb/s), as opposed to the slow 10Mb/s upload limit imposed by my ISP. I would also like to access the NC server on my LAN when the internet is down.

I searched this forum and the internet for solutions, but could not find any specific instructions, only vague comments to the effect that this should be possible.

My Nextcloud config.php file:

<?php
$CONFIG = array (
  'instanceid' => 'ocnxoo18681c',
  'passwordsalt' => 'FxxxxxxxxxxxRQD3b/V',
  'secret' => '4I3wxxxxxxxxxxxx',
  'trusted_domains' => 
  array (
    0 => 'xxxxx.com',
    1 => '192.168.1.40',
  ),
  'trusted_proxies' => 
  array (
    0 => '192.168.1.63',
  ),
  'datadirectory' => '/var/www/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '29.0.0.19',
  'overwrite.cli.url' => 'http://xxxxx.com',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextclouduser',
  'dbpassword' => '[xxxxxh',
  'installed' => true,
  'default_phone_region' => 'CA',
  'maintenance_window_start' => 8,
  'memories.db.triggers.fcu' => true,
  'memories.exiftool' => '/var/www/nextcloud/apps/memories/bin-ext/exiftool-amd64-glibc',
  'memories.vod.path' => '/var/www/nextcloud/apps/memories/bin-ext/go-vod-amd64',

My apache2 nextcloud.conf file:

<VirtualHost *:80>
    ServerName xxxxx.com
    DocumentRoot /var/www/nextcloud/

    # log files
    ErrorLog /var/log/apache2/files.xxxxx.com-error.log
    CustomLog /var/log/apache2/files.xxxxx.com-access.log combined

    <Directory /var/www/nextcloud/>
        Options +FollowSymlinks
	AllowOverride All

	<IfModule mod_dav.c>
	    Dav off
	</IfModule> 

	SetEnv HOME /var/www/nextcloud
	SetEnv HTTP_HOME /var/www/nextcloud
     </Directory>
</VirtualHost>

Any help appreciated.

Have you tried
192.168.1.40/nextcloud

as the address?

The IP by itself leads to the Apache landing page by default, so you have to specify where you want to go. Usually that’s done by adding /nextcloud to the IP, but depending on your setup it could be different.

http://192.168.1.40/nextcloud gives this:
image

Same thing with http://192.168.1.40/index.php/apps/dashboard/

Changing the server name in my apache nextcloud.conf file from my NC domain name to my server’s IP address:

<VirtualHost *:80>
    ServerName 192.168.1.40
    DocumentRoot /var/www/nextcloud/

    # log files
    ErrorLog /var/log/apache2/files.xxxxx.com-error.log
    CustomLog /var/log/apache2/files.xxxxx.access.log combined

    <Directory /var/www/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All

        <IfModule mod_dav.c>
            Dav off
        </IfModule>

        SetEnv HOME /var/www/nextcloud
        SetEnv HTTP_HOME /var/www/nextcloud
     </Directory>
</VirtualHost>

then restarting apache (systemctl restart apache2) and then pointing a browser (Firefox) to http://192.168.1.40/apps/dashboard/#/ works, but I no longer have WAN access. I guess I could do that manually each time I need to …

You can add the IP by using the ServerAlias directive, as follows…

<VirtualHost *:80>
    ServerName xxxxx.com
    ServerAlias 192.168.1.40
    DocumentRoot /var/www/nextcloud/

    # log files
    ErrorLog /var/log/apache2/files.xxxxx.com-error.log
    CustomLog /var/log/apache2/files.xxxxx.access.log combined

    <Directory /var/www/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All

        <IfModule mod_dav.c>
            Dav off
        </IfModule>

        SetEnv HOME /var/www/nextcloud
        SetEnv HTTP_HOME /var/www/nextcloud
     </Directory>
</VirtualHost>

And I would also recommend disabling the default virtualhost:

a2dissite 001-default.conf && systemctl restart apache2

The default Apache webroot is in /var/www/html, so 192.168.1.40/nextcloud wouldn’t work. To make it work, Nextcloud would have to be installed in /var/www/html/nextcloud and the path in the <Directory> section of the above configuration would have to be changed accordingly and then the section would have to be added to the <VirtualHost> section of the 000-default.conf file. However, I wouldn’t recommend using subdirectories, unless you want to access multiple services on the same server by IP address, which I wouldn’t recommend in the first place.

A better way to do this would be to use local DNS / split-brain DNS, so that you can access all your services via FQDN (Fully Qualified Domain Name) also from your local network. So even the solution I suggested above with the ServerAlias directive, while probably working for @rcjca’s use case, is only a suboptimal solution, imho.

Many many thanks. The ‘ServerAlias’ directive worked. I also disabled the default virtual host as suggested. I can now access NC from both my LAN and WAN. :grinning:

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.