0

I'm running an apache server with icinga, some personal static stuff, and nextcloud. How I'd like this to work is as follows;

domain/ (all my static stuff)
      /nextcloud
      /icingaweb2

the directory structure is

/var/www/html (all my personal stuff)
/var/www/nextcloud

The config for this is

<VirtualHost *:80>
ServerAdmin <email>
DocumentRoot "/var/www/html"
ServerName <url>
Alias  "/nextcloud/" "../nextcloud"

Options MultiViews FollowSymlinks
<Directory "nextcloud/">  
AllowOverride All
Order allow,deny
Allow from all
</Directory>
TransferLog /var/log/apache2/nextcloud_access.log
ErrorLog /var/log/apache2/nextcloud_error.log
</VirtualHost>%     

I'm not exactly sure how Icinga works, but it and the static part is fine. Nextcloud isn't and I get a Forbidden 403 for this.

This config works, but none of the static stuff does;

<VirtualHost *:80>
ServerAdmin <email>
DocumentRoot "/var/www/nextcloud"
ServerName <url>
<Directory "/var/www/nextcloud/">
Options MultiViews FollowSymlinks

AllowOverride All
Order allow,deny
Allow from all
</Directory>
TransferLog /var/log/apache2/nextcloud_access.log
ErrorLog /var/log/apache2/nextcloud_error.log
</VirtualHost>% 

I'm running Debian BTW, Thanks

Freddy
  • 2,039
  • 7
  • 13
James
  • 101
  • 14

2 Answers2

0

Have you done a chown www-data:www-data -R /var/www/nextcloud to give apache2 ownership on the files?

Marc
  • 1
  • 2
  • Yes, checked that all out. Oddly though /var/www/html is a root:root and that works, but I've check the apache user and group are www-data. Also I've had this working in other configurations, I just can't get both working together – James Sep 29 '19 at 21:13
0

The common way is to use an Alias with an absolute path and a <Directory/> directive with the same path like this:

<VirtualHost *:80>
    ServerName <url>
    ServerAdmin <email>
    DocumentRoot /var/www/html

    Alias /nextcloud/ /var/www/nextcloud
    <Directory /var/www/nextcloud>
        # --> enable stuff if needed, this should already be enabled in apache.conf
        #Options Indexes FollowSymLinks
        #AllowOverride None
        #Require all granted
    </Directory>

    # add logging etc.
</VirtualHost>

If you need access control and have an Apache >=2.4, replace the deprecated syntax

Order allow,deny
Allow from all

with

Require all granted

See https://httpd.apache.org/docs/current/upgrading.html

Freddy
  • 2,039
  • 7
  • 13
  • Tried this config, but get /var/www/nextcloud/: No matching DirectoryIndex (index.php,index.html,index.cgi,index.pl,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive – James Sep 29 '19 at 21:22
  • Remove the comment from the `Options` line and add the ones you need. At least the `Alias` seems to work now. – Freddy Sep 29 '19 at 21:34