✓ Solved

Setup 2nd website after deploying nextcloud linode.

I'm having trouble setting up another website on same server I deployed linode nextcloud.

Nextcloud working fine. No problems, been using for a while. I decided to try setting up a 2nd website on linode using the same apache server. Followed some guides available online. After setting up, 2nd site keeps going to nextcloud login. Tried from several different devices and different browsers. All goes to nextcloud site. I have collected some info and will paste below.

contents of /etc/apache2/sites-enabled/othersite.conf

<VirtualHost *:80>
     ServerAdmin notroot@localhost.com
     ServerName othersite.dname.com
     DirectoryIndex index.html
     DocumentRoot /var/www/othersite/public_html/
     ErrorLog /var/www/othersite/logs/error.log
     CustomLog /var/www/othersite/logs/access.log combined

contents of nextcloud conf file in enabled:

Alias / "/var/www/nextcloud/"
<Directory /var/www/nextcloud/>
  Options +FollowSymlinks
  AllowOverride All
<IfModule mod_dav.c>
  Dav off
SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud

<VirtualHost *:80>
  ServerName nextcloud.dname.com
  ServerAdmin admin@localhost.com
  DocumentRoot /var/www/nextcloud
  <directory /var/www/nextcloud>
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews
    SetEnv HOME /var/www/nextcloud
    SetEnv HTTP_HOME /var/www/nextcloud
RewriteEngine on
RewriteCond %{SERVER_NAME} =nextcloud.dname.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

Output of apache2 -S:

notroot@dname:~$ sudo apachectl -S
AH00548: NameVirtualHost has no effect and will be removed in the next release /etc/apache2/ports.conf:1
VirtualHost configuration:
*:443                  nextcloud.dname.com (/etc/apache2/sites-enabled/nextcloud-le-ssl.conf:2)
*:80                   is a NameVirtualHost
         default server othersite.dname.com (/etc/apache2/sites-enabled/othersite.conf:2)
         port 80 namevhost othersite.dname.com (/etc/apache2/sites-enabled/othersite.conf:2)
         port 80 namevhost othersite.dname.com (/etc/apache2/sites-enabled/nextcloud.conf:13)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
User: name="www-data" id=33
Group: name="www-data" id=33

header info from curl request:

notroot@dname:~$ curl -s -D headers.txt -o /dev/null http://othersite.dname.com
notroot@dname:~$ less headers.txt
HTTP/1.1 302 Found
Date: Fri, 06 May 2022 16:16:57 GMT
Server: Apache/2.4.38 (Debian)
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Robots-Tag: none
X-XSS-Protection: 1; mode=block
Set-Cookie: ocsk6whwcglg=csfnd5l56vvrh2qfdr6fnc8ujd; path=/; HttpOnly; SameSite=Lax
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Set-Cookie: oc_sessionPassphrase=B9SOCOy8ayQZmY30Ji62Ulh%2BPJObvtV0bQcrZDXr3KB1q%2B53RkGWmXxRlTmyarFo9lOJ3827nDyebzSRIbcFXAhfapa92IzNXm08X6zY4IY5FpQ9UN%2FXbFk8ws8kIjBm; path=/; HttpOnly; SameSite=Lax
Set-Cookie: ocsk6whwcglg=61o1ajah6p0hnul0en2btt061u; path=/; HttpOnly; SameSite=Lax
Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-ajBkODRuZlFhS0tSUnZPbVhtM0dXbUY0SmF5SUZBWUlyNXFFOUwrOEFMQT06eFNNYXBFK3FLWlB5QkxUY0tpZVdIQ01QYXRYU1lYNWMzL2l3cDhyTWJkaz0='; style-src 'self' 'unsafe-inline'; frame-src *; img-src * data: blob:; font-src 'self' data:; media-src *; connect-src *; object-src 'none'; base-uri 'self';
Set-Cookie: nc_sameSiteCookielax=true; path=/; httponly;expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=lax
Set-Cookie: nc_sameSiteCookiestrict=true; path=/; httponly;expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=strict
Location: http://othersite.dname.com/index.php/login
Content-Length: 0
Content-Type: text/html; charset=UTF-8

The curl header output has the ‘othersite’ in the location:

Location: http://othersite.dname.com/index.php/login

The virtual hosts are using the same IP and the dns seems to be routing to that IP ok. It ‘seems’ to be a php setting that I’m not familiar with that maybe? redirecting to nextcloud? I don’t have any php or any other processing lang setup for the other site. Just serving static html files.

output of folder permissions

ls -l /var/www/
total 12
drwxr-xr-x  2 root     root     4096 Feb 27  2021 html
drwxr-xr-x  4 www-data www-data 4096 May  5 21:14 othersite
drwxr-xr-x 14 www-data www-data 4096 May  5 18:48 nextcloud

Restarted apache, reloaded configs manually… Used different browsers on different devices. All times goes to nextcloud site’s login. Does not go to othersite’s index.html

notroot@dname:~$ ls -l /var/www/othersite/public_html/
total 12
lrwxrwxrwx 1 www-data www-data   42 May  5 21:20 index.html -> /var/www/othersite/public_html/wordle.html
-rw-r--r-- 1 www-data www-data 9725 May  5 21:19 wordle.html

1 Reply

✓ Best Answer

Got help from nextcloud web forums to solve problem.

Apparently this line:

Alias / "/var/www/nextcloud/"

in nextcloud.conf which is TOP line in the conf file forces all traffic to serve from nextcloud folders. The conf file wasn't created or edited by me. It was either put in place by linode's default nextcloud VM, or by one of nextcloud's built in auto update scripts.

I guess unless your familiar with the format of the conf files, you will have to be wary of the default conf files put in place by linode's nextcloud templates or nextcloud update tools. For anyone else thinking about adding additional sites to linode nextcloud VMs, keep this possibility in mind.


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct