Koozali.org: home of the SME Server

Dedicated domain not directing to /usr/share/nextcloud

Offline Mace

  • **
  • 65
  • +0/-0
Dedicated domain not directing to /usr/share/nextcloud
« on: June 17, 2021, 05:42:55 AM »
I'm almost there  :-)

I have Nextcloud running well. I followed the steps at https://wiki.koozali.org/Nextcloud#Use_a_dedicated_domain_to_connect_to_Nextcloud and finally got LetsEncrypt to successfully gave me certs for my main domain, which I'll call mydomain.com, and one for nextcloud.mydomain.com after the domain property letsencryptSSLcert was set on both mydomain.com and nextcloud.mydomain.com

When I go to any of the following addresses (all https://) it shows the content of the Primary I-bay instead of /usr/share/nextcloud:

nextcloud.mydomain.com
nextcloud.mydomain.com/nextcloud
mydomain.com/nextcloud
my-external-ip/nextcloud

When I go to my-internal-ip/nextcloud it comes up correctly.

I verified all the db config options are correct according to the Nextcloud contrib wiki. Could it be that SME thinks that nextcloud.mydomain.com and mydomain.com are two separate domains instead of nextcloud.mydomain.com being a host belonging to mydomain.com? That's all I can think of at the moment.

Sorry if it's something obvious. I think I'm very close to it working though.

Offline Mace

  • **
  • 65
  • +0/-0
Re: Dedicated domain not directing to /usr/share/nextcloud
« Reply #1 on: June 17, 2021, 09:41:35 AM »
I missed an important parameter. I set it to public with
Code: [Select]
config setprop nextcloud access public
and now have it working on

nextcloud.mydomain.com/nextcloud
mydomain.com/nextcloud
my-external-ip/nextcloud

but still not with just

nextcloud.mydomain.com which is what all my existing sync clients are set up on.

I will update this post if I figure this last bit out.
« Last Edit: June 17, 2021, 10:18:20 AM by Sterling »

Offline Mace

  • **
  • 65
  • +0/-0
Re: Dedicated domain not directing to /usr/share/nextcloud
« Reply #2 on: June 18, 2021, 03:16:43 AM »
Still can't get it working. Anyone have any ideas on how to get it working without having to use the /nextcloud directory after the domain? Not sure what the proper way to add it as a virtual host might be.
« Last Edit: June 18, 2021, 09:46:00 AM by Sterling »

Offline Mace

  • **
  • 65
  • +0/-0
Re: Dedicated domain not directing to /usr/share/nextcloud
« Reply #3 on: June 28, 2021, 07:12:57 PM »
Is what I'm trying to achieve possible?

Offline Jean-Philippe Pialasse

  • *
  • 2,743
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Dedicated domain not directing to /usr/share/nextcloud
« Reply #4 on: June 28, 2021, 09:02:50 PM »
that is how it is configured on my SME9 that is awaiting migration.

Code: [Select]
# db domains show mycloud.mydomain.com
mycloud.mydomain.com=domain
    Content=Primary
    Description=Nextcloud
    DocumentRoot=/usr/share/nextcloud
    Nameservers=internet
    RequireSSL=enabled
    TemplatePath=WebAppVirtualHost
    letsencryptSSLcert=enabled

Code: [Select]
# config show nextcloud
nextcloud=service
    AdminPassword=REDACTED
    AdminUser=REDACTED
    CloudDomain=mycloud.mydomain.com
    DbName=REDACTED
    DbPassword=REDACTED
    DbUser=REDACTED
    ExcludeIbay=Primary,arch,rep
    PHPBaseDir=/media/video/:/home/e-smith/files/ibays/music/files
    TrustedDomains=
    access=public
    status=enabled
    updater.secret=REDACTED


and I get in httpd.conf

Code: [Select]
<VirtualHost 0.0.0.0:80>

    ServerName mycloud.mydomain.com
    ServerAlias REDACTED

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*
    RewriteRule ^/(.*|$) https://%{HTTP_HOST}/$1 [L,R]



    RewriteEngine on
    RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
    RewriteRule .* - [F]



    # alias for Apache icons
    Alias /icons/ /var/www/icons/


    DocumentRoot /usr/share/nextcloud


</VirtualHost>


<VirtualHost 0.0.0.0:443>

    ServerName mycloud.mydomain.com
    ServerAlias REDACTED

    SSLEngine on


    RewriteEngine on
    RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
    RewriteRule .* - [F]



    # alias for Apache icons
    Alias /icons/ /var/www/icons/


    DocumentRoot /usr/share/nextcloud


</VirtualHost>

starting sme10  /etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost/ is provided by core and does not need smeserver-webapps-common contrib.


beware to typo, and also declaration of domain using cli is mandatory, at least to define the  TemplatePath=WebAppVirtualHost

Offline Mace

  • **
  • 65
  • +0/-0
Re: Dedicated domain not directing to /usr/share/nextcloud
« Reply #5 on: June 29, 2021, 10:48:37 AM »
My config shows the following:

Code: [Select]
# db domains show nextcloud.mymaindomain.com
nextcloud.mymaindomain.com=domain
    Content=Primary
    Description=Nextcloud
    DocumentRoot=/usr/share/nextcloud
    Nameservers=internet
    RequireSSL=enabled
    TemplatePath=WebAppVirtualHost
    letsencryptSSLcert=enabled
Code: [Select]
# config show nextcloud
nextcloud=service
    AdminPassword=REDACTED
    AdminUser=REDACTED
    CloudDomain=nextcloud.mymaindomain.com
    DbName=REDACTED
    DbPassword=REDACTED
    DbUser=REDACTED
    TrustedDomains=
    VirtualHost=nextcloud.mymaindomain.com
    access=public
    status=enabled

Yet I have no VirtualHost entries for nextcloud.mymaindomain.com in /etc/httpd/conf/httpd.conf, but just mymaindomain.com and the other domains I have entered via the servermanager web interface do have VirtualHost entries. Could another contrib be blocking it from expanding properly?

Offline Jean-Philippe Pialasse

  • *
  • 2,743
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Dedicated domain not directing to /usr/share/nextcloud
« Reply #6 on: June 29, 2021, 12:02:55 PM »
expand-template /etc/httpd/conf/httpd.conf



any error ?

Offline Mace

  • **
  • 65
  • +0/-0
Re: Dedicated domain not directing to /usr/share/nextcloud
« Reply #7 on: June 29, 2021, 07:27:36 PM »
Ah yes, that does give errors.
Code: [Select]
# expand-template /etc/httpd/conf/httpd.conf
ERROR in /etc/e-smith/templates//etc/httpd/conf/httpd.conf/WebAppVirtualHost/25SSLDirectives: Program fragment delivered error <<syntax error at /etc/e-smith/templates//etc/httpd/conf/httpd.conf/WebAppVirtualHost/25SSLDirectives line 5, near "){"
syntax error at /etc/e-smith/templates//etc/httpd/conf/httpd.conf/WebAppVirtualHost/25SSLDirectives line 23, near "}
    }">> at template line 1
WARNING in /etc/e-smith/templates//etc/httpd/conf/httpd.conf/80VirtualHosts: ERROR: Template processing failed for //etc/httpd/conf/httpd.conf/WebAppVirtualHost: 1 fragment generated errors
 at /etc/e-smith/templates//etc/httpd/conf/httpd.conf/80VirtualHosts line 40.
ERROR in /etc/e-smith/templates//etc/httpd/conf/httpd.conf/WebAppVirtualHost/25SSLDirectives: Program fragment delivered error <<syntax error at /etc/e-smith/templates//etc/httpd/conf/httpd.conf/WebAppVirtualHost/25SSLDirectives line 5, near "){"
syntax error at /etc/e-smith/templates//etc/httpd/conf/httpd.conf/WebAppVirtualHost/25SSLDirectives line 23, near "}
    }">> at template line 1
WARNING in /etc/e-smith/templates//etc/httpd/conf/httpd.conf/80VirtualHosts: ERROR: Template processing failed for //etc/httpd/conf/httpd.conf/WebAppVirtualHost: 1 fragment generated errors
 at /etc/e-smith/templates//etc/httpd/conf/httpd.conf/80VirtualHosts line 40.
WARNING: Template processing succeeded for //etc/httpd/conf/httpd.conf: 2 fragments generated warnings
 at /sbin/e-smith/expand-template line 45.

I wonder if it has something to do with LetsEncrypt.
« Last Edit: June 29, 2021, 08:38:06 PM by Sterling »

Offline Jean-Philippe Pialasse

  • *
  • 2,743
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Dedicated domain not directing to /usr/share/nextcloud
« Reply #8 on: June 29, 2021, 10:14:41 PM »
/etc/e-smith/templates//etc/httpd/conf/httpd.conf/WebAppVirtualHost/25SSLDirectives

is part of smeserver-php


please raise a bug.

Offline Mace

  • **
  • 65
  • +0/-0
Re: Dedicated domain not directing to /usr/share/nextcloud
« Reply #9 on: June 29, 2021, 11:00:44 PM »
/etc/e-smith/templates//etc/httpd/conf/httpd.conf/WebAppVirtualHost/25SSLDirectives

is part of smeserver-php


please raise a bug.
Thanks, done.
https://bugs.koozali.org/show_bug.cgi?id=11641

Offline Mace

  • **
  • 65
  • +0/-0
Re: Dedicated domain not directing to /usr/share/nextcloud
« Reply #10 on: June 30, 2021, 01:53:29 AM »
Lastly, could you verify which template or configuration key/value I should put the following (if supported)?
Code: [Select]
'overwrite.cli.url' => 'https://nextcloud.mymaindomain.com',
'htaccess.RewriteBase' => '/',
Thank you!

[edit]
Trying to achieve https://docs.nextcloud.com/server/20/admin_manual/installation/source_installation.html?highlight=root%20domain#pretty-urls

I guess I can just edit config.php directly like in that link since there is no /etc/e-smith/templates/usr/share/nextcloud/?
« Last Edit: June 30, 2021, 02:27:33 AM by Sterling »

Offline Jean-Philippe Pialasse

  • *
  • 2,743
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Dedicated domain not directing to /usr/share/nextcloud
« Reply #11 on: June 30, 2021, 06:13:39 AM »
i am not there yet. if you manage to fix this go and explain how and i will implement it. 

Offline Mace

  • **
  • 65
  • +0/-0
Re: Dedicated domain not directing to /usr/share/nextcloud
« Reply #12 on: June 30, 2021, 07:29:27 AM »
To remove the index.php-part in all Nextcloud URLs I added
Code: [Select]
'overwrite.cli.url' => 'https://nextcloud.mymaindomain.com',
'htaccess.RewriteBase' => '/',

to /usr/share/nextcloud/config/config.php and then ran
Code: [Select]
occ maintenance:update:htaccess
to activate those new config changes.

The two lines are a little different if you don't use a dedicated hostname and instead access your Nextcloud with yourdomain.com/nextcloud. See https://docs.nextcloud.com/server/20/admin_manual/installation/source_installation.html?#pretty-urls for details.

Everything seems to be working very well. As long as config.php doesn't get overwritten it seems it should continue to work.
« Last Edit: June 30, 2021, 07:34:07 AM by Sterling »