Change name of virtual host

[/details]

Nextcloud version (eg, 12.0.2): 17.0.1
Operating system and version (eg, Ubuntu 17.04): Ubuntu 18.04
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.29
PHP version (eg, 7.1): 7.2

The issue you are facing:

Is this the first time you’ve seen this error? (Y/N): Not a “problem”, rather something I would like to do, but I don’t know how to do it.

I am currently using nextcloud using a dynamic dns service (dynu.com) with a web address such as cloud.xxxxx.dynu.com. Now I have registered a domain name for email and would like to use the same domain name for my Nextcloud. This is partly because then I can get letsencrypt and don’t need to pay for a certificate renewal every year. Letsencrypt hasn’t been working for dynu.com addresses. Now how do I go about this? First I thought I could just create a new virtual host file for the new address (cloud.xxxx.link) but now I have doubts. Any help is appreciated. I am not very good at understandning virtual hosts and Apache configuration files, but I have had some success setting up nextcloud and email services using tutorials, manuals and forums.

Hi, Welcome to the Forum.

First: Where are you hosting.

If you host at home you have the problem of having a dynamic (changing) IP Adress.
At your Domain Registration, where you must point your IP to a specific IP Adress. DynDNS Services exist exactly becuase of that problem.

If you have a webhoster, with static IP, then there are (from the rear of my head) following steps:
Point cloud.yourdomain.com to your IP.
Maybe you have to allow HTTP again, if you disabled it. You can switch that back afterwards.
Change the entry regarding cloud.xxxxx.dynu.com to cloud.yourdomain.com in your config.php
setup letsencrypt.

See, your local webserver really doesnt give a damn about your Domainname. The Application Nextclound on the other hand does.

Careful: If you have used HSTS (if you dont know what it is, then you probaly not) you may have difficulties accessing your Server via plain HTTP.

Thanks for the reply!
I run the server at home, with dynamic IP, hence I use dynu.com for translating the web address of my server to my dynamic IP number. At the moment both my mail.xxxxx.link and cloud.xxxxx.dynu.com point to the same IP, without problems. But now I want to use .link addresses for all my services.
Hope this makes it clear.

I´m not sure. A few questions:

Is the new DNS also a dyndns service of the kind you already have?
If not, i see problems with that.

Does the IP stay the same? Double check that if in doubt.

The Webserver is agnostic about your ip, it CAN change. But if your ip Changes AND your ‘A Record’ in the DNS system is STATIC (which is the absolute Norm, except for DynDNS Service which are rare), then your site will fail after the first IP change.

I hope we are on the same page somehow :slight_smile:

Sure, the new adress uses dynu.com too. And I do have a service running on my server that takes care of ip changes. Nothing new there. As to your other questions, they are also under control. I think that all I need is a new conf file in /etc/apache2/sites-available with ssl certificate (that I intend to get from letsencrypt) and possibly some other changes in e.g. php.conf. But I don’t know how to get a conf file for a new virtual host up and running in parallel to my existing one. I don’t think I can just copy the existing one because the ssl certificate needs to be different. Am I on the right track? Do I need to disable the existing virtual host before I fly the new one?

I was thinking other people might have done this before and maybe there is even a tutorial out there, although I haven’t found it.

Thanks again for the help!

Den 19 dec. 2019, kI 01:50, Gerald Buttinger via Nextcloud community noreply@nextcloud.com skrev:

Ah, ok. Now i get it.

I dont think you need a new vHost in Apache at all.

You can do it that way, but i would just change the necessary entries in your current sites-available config file.

find the line there where your current ssl cert is referenced > Comment it out > Craft a new line pointing to the new cert (dont know how letsencrypt wants this though) > service apache restart or the like.

Make a backup of your apache config file so you can revert to it at any time, and play with it. It´s not rocket science :wink:

Great. Just one thing (I’m not at my computer now) which entries in the config file, except ssl? I don’t see how I tell the config file which adress it serves. I suppose this is basic Apache2 knowledge but it’s a mystery to me, which I would love to have solved.

Den 19 dec. 2019, kI 09:49, Gerald Buttinger via Nextcloud community noreply@nextcloud.com skrev:

Hi, glad i could help a little :slight_smile:

Your question is indeed related to very basic stuff. See:
You make a request in your browser via Domainname it gets translated by DNS and the request is directly sent to this ip. So far so simple.

Next comes your Apache and serves the webpage configured in its config file to whoever makes the request. Normally you have a <VirtualHost *:80> or similar in there. This means it catches every request on port 80. and serves content. The webserver does not know, and doesnt need to know the actual domain name. It is completley unaware of it, its only DNS pointing to your server. Your could replace the * with your ip or domainname, but you really dont need to.

The certificate must have the right DNS Name in it, thats all.

Ok, I think I get it. The *:80 catches all I coming http requests. But if I have several virtual hosts I suppose I can’t use the wildcard.
I will try to put this into practice sometime soon. Thanks!

You can of course use the wildcard, but you cannot use the same port twice.

I´m not a pro at apache, and have never used different vHosts, or non wildcard bindings, so i hope i dont tell crap, but i´m relativley confident, that this is the case.