You are not logged in.

#1 2025-02-10 09:51:50

Salkay
Member
Registered: 2014-05-22
Posts: 663

Nextcloud's DirectoryIndex is not working on LAN

I've been using Nextcloud on an Apache server, which has been working fine for the better part of a decade. However when connecting from LAN, DirectoryIndex doesn't seem to work any more. Specifically, I can connect fine to https://foo.com/nextcloud/login, but I can't connect to https://foo.com/nextcloud. I get the following error in my browser:

Forbidden
You don't have permission to access this resource.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

In /var/log/httpd/error_log I can see

[Mon Feb 10 20:37:31.521791 2025] [autoindex:error] [pid 2467:tid 2495] [client 192.168.1.81:53260] AH01276: Cannot serve directory /usr/share/webapps/nextcloud: No matching DirectoryIndex (none) found, and server-generated directory index forbidden by Options directive

Oddly enough, DirectoryIndex seems to work when I connect from the internet. I've basically followed the instructions in the Arch wiki. Specifically, /etc/httpd/conf/httpd.conf contains Include conf/extra/nextcloud.conf, then /etc/httpd/conf/extra/nextcloud.conf contains

Alias /nextcloud /usr/share/webapps/nextcloud

<Directory /usr/share/webapps/nextcloud>
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews

    DirectoryIndex index.php index.html

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

( I have the php nextcloud.sock defined elsewhere.) I wasn't sure if some other config was overriding DirectoryIndex, so I grepped through /etc/httpd/conf for DirectoryIndex, but every line contained index.html and also usually index.php. How can I get DirectoryIndex to work?

[EDIT] It's also weird that it works from the internet but not LAN. If relevant, I have my router's DNS set up to map traffic to foo.com to my server's internal static IP.
[EDIT2] I don't think it's an issue in my Nextcloud config either. FWIW my config.php has the following

  'trusted_domains' => 
  array (
    0 => '192.168.1.91',
    1 => 'foo.com',
  ),

Which should allow connections from both LAN and internet. This indeed works generally... just not for DirectoryIndex.

Last edited by Salkay (2025-02-10 10:42:01)

Offline

#2 2025-02-10 09:56:21

cryptearth
Member
Registered: 2024-02-03
Posts: 1,337

Re: Nextcloud's DirectoryIndex is not working on LAN

Offline

#3 2025-02-10 10:40:14

Salkay
Member
Registered: 2014-05-22
Posts: 663

Re: Nextcloud's DirectoryIndex is not working on LAN

Thanks @cryptearth but I'm not sure if that's relevant? From your link, this seems to be relevant if

the directory does not contain a filename that matches the DirectoryIndex directive

but here (from the log) I think my issue is that there is no DirectoryIndex directive parsed at all. Also, I think my internet vs. LAN issues suggest it's possibly more complicated than that.

In any case, I tested adding the option of either +Indexes or -Indexes to /etc/httpd/conf/extra/nextcloud.conf, and in both cases I couldn't connect at all, with ERR_CONNECTION_REFUSED.

Offline

#4 2025-02-10 13:24:48

cryptearth
Member
Registered: 2024-02-03
Posts: 1,337

Re: Nextcloud's DirectoryIndex is not working on LAN

according to https://httpd.apache.org/docs/2.4/en/mo … ml#options you need
Options Indexes - within the directory you want to auto-generate indexes if no index.xxx is found, along with
mod_autoindex enabled
you con_rej hints there's some config error and hence apache not start up at all - please check journal for parsing errors
also check enabled modules
otherwise check DirectoryIndex for the value "disabled"
as for why the server behaves differently could be due to different virtusl hosts bound to different SNIs

Offline

#5 2025-02-10 21:49:37

Salkay
Member
Registered: 2014-05-22
Posts: 663

Re: Nextcloud's DirectoryIndex is not working on LAN

Thanks again @cryptearth.

you want to auto-generate indexes

As per my OP, from LAN, https://foo.com/nextcloud fails to load. However, if I manually go to https://foo.com/nextcloud/index.html (or https://foo.com/nextcloud/index.php), the page does correctly load (redirecting to https://foo.com/nextcloud/login). So I don't think it's an issue of index.xxx not existing. Rather, it's an issue of DirectoryIndex not correctly redirecting https://foo.com/nextcloud to index.xxx. I don't think we want to generate indices do we?

hence apache not start up at all

I'm don't think this is the case, because apache is serving almost all other "normal" pages fine, it's just DirectoryIndex failing. Further, the other DirectoryIndex directives seem to be working correctly. e.g. https://foo.com serves https://foo.com/index.html; https://foo.com/tt-rss serves https://foo.com/tt-rss/index.php.

otherwise check DirectoryIndex for the value "disabled"

Yeah I originally suspected this might be the case. But from my OP

I grepped through /etc/httpd/conf for DirectoryIndex, but every line contained index.html and also usually index.php

So I think it should be fine.

as for why the server behaves differently could be due to different virtusl hosts bound to different SNIs

I don't really understand this enough to troubleshoot, but I did have a grep in /etc/httpd/conf for VirtualHost, and found references to *:80, *:443, _default_:443. The earliest reference (via Includes in /etc/httpd/conf/httpd.conf is in /etc/httpd/conf/extra/httpd-vhosts.conf. This says

# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.

I can see both <VirtualHost *:80> and <VirtualHost *:443> blocks in this file. I tested adding DirectoryIndex index.php index.html to these blocks, but it still failed.

Offline

Board footer

Powered by FluxBB