How to setup subdomain to nextcloud at home, step by step?

0

Recently I did setup on my Raspberry Pi Nextcloud 15 and I really would like to put it under a subdomain like cloud.mydomain.me but can’t figure out how to accomplish it the right way.

My IP is public(so no DDNS issue), the domain is kept at namecheap.com and apache2 is used as web server, I would like to be able to load the normal index.html(at /var/www/html/) at mydomain.me meanwhile access the nextcloud instance at cloud.mydomain.me instead of mydomain.me/nextcloud(the default). I’m also using certbot for Certificate generation, from what I understood I need to generate the certificate both for mydomain.me and cloud.mydomain.me but through the sudo certbot --apache the setup found only cloud.mydomain.me as an option.

What should I setup at Namecheap as host records? What should I setup in the Apache config(000-default.conf)? What should I setup in the config.php(at /var/www/html/nextcloud/config/)? What should I setup to get certbot being able to see and generate the certs both for mydomain.me and cloud.mydomain.me?

I looked on the web for this type of guidance but they just skip on details on the setup of those parts that I can’t grasp because I’m a noob but still looking to accomplish this setup :)

Ask me any more details if necessary.

PS: ports 80 and 443 to the Raspberry Pi local address are already open to the outside.

The output of my apache 000-default.conf:

<VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]

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

<VirtualHost *:443>
    ServerName cloud.mydomain.me

    <IfModule mod_headers.c>
        Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
    </IfModule>
    SSLCertificateFile /etc/letsencrypt/live/cloud.mydomain.me/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/cloud.mydomain.me/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

The output of my config.php file in /var/www/html/nextcloud/config/:

<?php
$CONFIG = array (
  'instanceid' => 'REDACTED',
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' =>
  array (
    0 => '192.168.1.226',#LAN IP Address
    1 => 'REDACTED',#public IP Address
    2 => 'cloud.mydomain.me'
  ),
  'datadirectory' => '/var/nextcloud/data',
  'dbtype' => 'sqlite3',
  'version' => '15.0.6.1',
  'overwrite.cli.url' => 'https://192.168.1.226/nextcloud',
  'htaccess.RewriteBase' => '/',
  'dbname' => 'cloud',
  'installed' => true,
  'updater.secret' => 'REDACTED',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
);

DNS records: namecheap dns records

Eugene

Posted 2019-04-05T20:04:44.303

Reputation: 101

No answers