Run other website parallel

Hi,
I am hosting a nextcloud server for personal use and would like to run a personal webpage on the same server. I have tried to edit the config files for virtual host but with no luck.

I have to dns names “mynextcloud” and “personalpage”

What get is when I try to access “personalpage” is 401 or if I try to access “https://personalpage” i get to the “mynextcloud”.

<VirtualHost *:443>
       ServerName mynextcloud.com

        ServerAdmin my@mail.com
        DocumentRoot /var/www/cloud

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on
RewriteCond %{SERVER_NAME} =mynextcloud
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:81>

        ServerName personalpage

        ServerAdmin my@mail.com
        DocumentRoot /var/www/personal

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

I have added port 81 is the ports.conf file as well. Does anyone have experience running another webpage parallel with nextcloud?

I’m biased, but that’s the kind of thing the UBOS Linux distro was made for: run any number of apps, including Nextcloud, in parallel at the same virtual host or at different ones, all without editing config files at all. No strange port numbers required either.

P.S. Biased because it’s my project.

You just need two different virtual host sections. One complete/full section for each domain. Both can run on the same port. You should not need the redirect statement. You also have not included ssl config in the virtualhost section.

<VirtualHost *:443>
    Protocols   h2 h2c http/1.1
    H2EarlyHints    on
        ServerName      xxxx.xxx
#        ServerAlias  
...logging, paths etc

    Header  append Vary: Accept-Encoding
    Header  always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
...
       SetEnv HOME "/var/www/domains/xxxxxxx/htdocs/nextcloud"
       SetEnv HTTP_HOME "/var/www/domains/xxxxx/htdocs/nextcloud"

    <FilesMatch \\.php$>
        SetHandler "proxy:unix:/run/php-fpm/php-fpm.socket|fcgi://localhost"
    </FilesMatch>

    SSLCertificateFile   /etc/letsencrypt/live/xxxxxxxxx/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/xxxxxxxxx/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf

I have edited both 000-default.config and 000-default-le-ssl.conf but still https://www.mywebpage.com is directing me to my nextcloud page. Is nextclpud taking all requests and directing it ti nextcloud. From what I have understood its “only” to add a virtual host but that does not seams to work.

<IfModule mod_ssl.c>
<VirtualHost *:443>
	ServerName mycloud

        <IfModule mod_headers.c>
		Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
        </IfModule>

	<Directory /var/www/html/>
		Options +FollowSymlinks
		AllowOverRide ALL
	</Directory>

	ServerAdmin my@email
	DocumentRoot /var/www/html

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined


SSLCertificateFile /etc/letsencrypt/live/mycloud/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mycloud/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

</IfModule>

<VirtualHost *:80>
        ServerName mywebpage

        ServerAdmin my@email
        DocumentRoot /var/www/mywebpage/webpage

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

This seems wrong. Should be *:443

Have tried all different ports; 80, 443, 81. Think the problem lies somewhere else, might be something with secure http for nectcloud, forgot to mention that I used certbot to secure the connection to my nextcloud.

Do you have nextcloud in this location.

try putting a testfile there instead

try putting a testfile there instead

I changed the RootDirectory for mycloud VirtualHost block to the directory of mywepage and I can access “mywebpage” from the url mycloud. The order och the block does not matter either.

Then I do not understand. You need to have a proper apache setup to serve the correct files. That has nothing to do with Nextcloud.

In your first post you show two domain named mynextcloud.com and personalpage (without .com?)

You should not use the rewrite rule in any of them.

VirtualHost statements work with SNI. This means that Apache will look at the browser’s request to determine what domain name (virtualhost section) to serve documents from. Your SSL certificates must be correct.

It sounds like you might be running Nextcloud on your_default_vhost (000-default.config + 000-default-le-ssl.conf) which is usually not what you want. See https://httpd.apache.org/docs/current/vhosts/examples.html

Use a separate config file for your hosted domains. Usually under /etc/apache/vhosts.d/somedomain.conf

Your configuration should look like this, assuming you have two domains mynextcloud.com and personalpage.com. There should be no need for any rewrite rules. Those are usually needed if you want to redirect from HTTP to HTTPS. In that case it should be under a separate <VirtualHost *:80> section.

<VirtualHost *:443>
	ServerName mynextcloud.com
	DocumentRoot /var/www/cloud
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
	ServerName personalpage.com
	DocumentRoot /var/www/personal
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

In your first post you show two domain named mynextcloud.com and personalpage (without .com ?)

A typo, it should be a .com after personalpage.

It sounds like you might be running Nextcloud on your_default_vhost (000-default.config + 000-default-le-ssl.conf) which is usually not what you want.

That is correct, I have now changed it to be one one cloud.conf and one personalpage.conf and have them enabled and disabled 000-default.config + 000-default-le-ssl.conf.

What I failed to mention before is that cloud.com is using https certified by certbot while a added personalpage.com after https is enabled. Personalpage.com use http.

What I find weird is that I am able to ping personalpage.com but not able to reach it in my browser. As well as when I type in my browser http://personalpage.com I get redirected to cloud.com.

It is all odd. Sorry for that.

I think a standard config should work.

<VirtualHost *:443>
	ServerName mynextcloud.com
	DocumentRoot /var/www/cloud
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
	ServerName personalpage.com
	DocumentRoot /var/www/personal
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Add some a file “hello.txt” in /var/www/personal/hello.txt and browse to http://personalpage.com/hello.txt

It should not redirect to Nextcloud unless there are some files in /var/www/personal/ that says so, or you have something in your apache config doing the redirect.

1 Like

I’ll give that a try, thanks for your help