[noob-question] How to have NC on a subdomain and something (maybe picoCMS?) on the domain's root?

Hi all,
I’m all round almost-noob, so sorry if I’m doing something wrong (such as asking this in the wrong place), but I would like to learn, so any help or suggestion would be really appreciated.

Context

I’ve installed NextCloudPi (NCP) on a Raspberry 4, flashing it on the sd card.
After that, I mooved the root partition (/) to a SDD connected through the USB3 port.

I configured a dynamic DNS (duckDNS) to access from outside, using ncp-config.
It worked well: I can access NCP through mydomain(dot)duckdns(dot)org.

After that, I bought a domain, lets say mydomain(dot)org.

Question

I would like to access my nextcloud through a subdomain, lets say (typical example, I spent a lot of time searching…) cloud(dot)mydomain(dot)org
& (and)
I would like to use my domain’s root (mydomain(dot)org) hosting some page, also static html pages, to start.
Ideally, I would like to have a pico cms page on the domain’s root (so that I can change it editing one .md file and pushing through git, but perhaps it is another story…).

Current Situation

Befor asking, I tried to do something, and I’ve elaborated some (partial and confused) ideas.

To have NCP on the subdomain, I added a CNAME record to the domain’s configuration panel, which points to cloud.mydomain.org .
So now I can access NCP using mydomain(dot)duckdns(dot)org OR cloud(dot)mydomain(dot)org.

This is cool, but right now if I try accessing to mydomain.org (so without subdomain) I obtain “nothing found, it’s impossible to reach the server” (or something similar, clearly I’m not native english and I obtained something equivalent).

I suppose the solution pass through editing /etc/apache2/avaiable-sites/nextcloud.conf, and I suppose that having just one (CNAME) record on my domain it is not enough… I spent some time on duckduckgo and on the apache documentation, but I’m anything but sure on how I can achieve this.

Conclusion

If you arrived till here, I really want to thank you for your kind patience.

Have a good day
BB

I’ve no clue how NextcloudPi is set up. But from your explanation it looks like it’s running Apache. You should be able to make a new config in /etc/apache2/sites-available/yourdomain.com.conf

On my phone atm so cba to give more detail but search how to set up virtual hosts in Apache, that’s probably what’s in /etc/apache2/sites-available/nextcloud.conf but don’t edit that, create a new one and the enable the new site config with command a2ensite or symlink that config to /etc/apache2/sites-enabled/

You need to add an “A” record pointing to your IP, for any domain and/or sub domain you want to use.

thank you very much @maetthew and @OliverV for your answers.

I added a “A” record on the DNS records of my domain provider. It refer to “@” (domain’s root) and point to the IP of mydomain on duckdns.

Moreover, I added website.conf in /etc/apache2/sites-avaiable/ and I configured as follows:

<VirtualHost _default_:*>
    DocumentRoot "/var/www/html"
    ServerName mydomainexample.org
</VirtualHost>

Current Situation

I can access through mydomain.org, but I’m still redirected to nextcloud login page (plus some error on the certificate… but it is another story too)

I didn’t change the nextcloud.conf in apache, but if it can help I can post it here

Thank you again for your help, if you have any further advice I would be grateful

Have a good day

You don’t need an “A” record. CNAME is perfectly fine if you have dynamic IP on your server and want to point your domain to a hostname instead.

@billibob24 Where is your Nextcloud web root stored? You need to place your new site in another directory and point the DocumentRoot in your virtual host config to that new directory. I’m guessing you have Nextcloud in /var/www/html and that’s why you get the Nextcloud login page when trying to access through your new domain name.

Don’t use _default_ but either

<VirtualHost *:443>

or

<VirtualHost *:80>

and the appropriate ServerName. AFAIR _default_ is for catching IP addresses and it usually does not do what you think it does.

Hello! I hope you have found the solution to your problems. But in case you you are still looking, here’s what I did in your situation.

(Please read this through first before jumping in, do appropiate backups and watch out for typos and simple mistakes!)

  1. Create a directory for your “frontpage”, the domain root, where you want to host your html or such

sudo mkdir -p /var/www/html/mydomain.net


2. Create a test file to be able to see when the page is working

sudo nano /var/www/html/mydomain.net/index.html

and put in some testing html.


3. Change the permissions of the domain folder recursively

sudo chmod -R 755 /var/www/html/mydomain.net


4. Change the user- and group ownership of the domainfolder to www-data

sudo chown -R www-data:www-data /var/www/html/mydomain.net


5. Create a conf file for your domains virtual host

sudo nano /etc/apache2/sites-available/mydomain.net.conf


6. Copy the nextcloud conf file to your newly-created domain's conf file by copy-paste or

sudo cat /etc/apache2/sites-available/nextcloud.conf > /etc/apache2/sites-available/mydomain.net.conf


7. In the file, change all the paths containing 'nextcloud' to 'mydomain.net' and check that the ServerName is set to mydomain.net

sudo nano /etc/apache2/sites-available/mydomain.net.conf


8. Go into nextcloud.conf and change ServerName value from mydomain.net to cloud.mydomain.net

sudo nano /etc/apache2/sites-available/nextcloud.conf


9. Enable your site by running

a2ensite


  1. Restart apache service

sudo systemctl restart apache2


Now you should be able to go to your browser and find the test html on mydomain.net and your cloud on cloud.mydomain.net

I had gotten my ssl-certificates at some point during all of this and if you have problems or errors with those, you probably have to run

sudo ncp-config

→ networking → letsencrypt
and get yours.


It's been a crazy hazy all-nighter but I hope I remembered everything! I think Number 8 was break-through for me after which things started finally working.
2 Likes

The problem is the pico files are md files. Apache looks for html or php files. So we will probably have to do some base URL rewrite magic or something, but I have no idea how.

If you use different vhosts, you can use specific configuration settings for the one using Nextcloud and the one using pico.

Well, for configuration tips around pico cms, please check their community…