How to use domain rather then ip

Hey, I have nextcloud installed in virtualbox with ubuntu

right now I am accessing it by ip:port

and now I want to change it and force it to use my domain name, I already setup ssl and I even connected the domain but when you enter via the domain it will change it to the url with the http and the ip

how can i force it to use the domain ? I already edited the nextcloud config

That must be done in the webserver, so you have to provide information about the webserver you are using.

If you use apache2:

You have various *.conf files for your virtual hosts:

for http:
which should contain these lines to redirect to https:

<VirtualHost *:80>
  RewriteEngine on
  RewriteCond %{REQUEST_URI} !^/\.well\-known/acme\-challenge/
  RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]

and for https:

<IfModule mod_ssl.c>
  <VirtualHost *:443>
    SSLEngine on
    ServerName your.domain.tld
    <IfModule mod_headers.c>
      Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"

Important is the combination of:

  <VirtualHost *:443>
    ServerName your.domain.tld

that makes it a → name based virtual host ←

And of course your dns should be configured to resolve your domain name but you wrote, that you can connect using domain.


  'trusted_domains' => 
  array (
    0 => 'your.domain.tld',
    1 => '<>',

I hope this helps!
Of course there is a lot more you can do but this is the basic configuration to enable the name based virtual host using https - which you need because some features like copy to clipboard does not work under http.

Much luck,

1 Like