Show domain instead of IP address

Hi!

I use nextcloud with a raspberry pi 3 (raspbian). I registered a domain.

When i enter my domain name the address bar resolves my (static) home ip, how do i manage to display myprivatecloud.at/nextcloud instead of 192.XXX.XXX.XXX/nextcloud?

I’ve read a lot about rewrite options, virtual host configurations but, as you may already have noticed, im a complete noob programming php and html or what else!

Can someone help?

Hi! So my guess is you have port forwarding done and you do not have a static IP address from your internet service provider, so you will have to do something like use the DuckDNS dynamic domain name service to associate your a domain name with a potentially changing IP address from your ISP. You will have to put your dynamic domain name in your web server settings (assuming it’s Apache, in the apache config file you made for your website) and then restart your web server.

Once that is complete, you will have to go to the website that you purchased your domain name from and see if they will let you create a CNAME record in their DNS settings. What you will do is point that CNAME record to your duckdns.org name that you created in DuckDNS. With the CNAME record name, you can put the purchased domain name in your apache config file and then reboot the server. Then, in your Nextcloud config file you will need to add both your dynamic domain name and your purchased name. I would also HIGHLY recommend getting an SSL/TLS certificate for your Nextcloud instance too

I do have a static IP! I do not have port forwarding because it wasn’t necessary.
Do I have to activate port forwarding? I use https with a self signed certificate.

You’ll have to use port forwarding or NAT so you can see the server from the outside of your place

Sorry, I’m stupid, I do have port forwarding :see_no_evil:

No worries, and you have your domain name in your Apache configs correct? You will also have to edit the config.php file in nextcloud/config to add your domain name to the trusted domains array, like:

'trusted_domains' =>
  array (
    '192.xxx.xxx.xxx',
    'demo.example.org',

  ), 

Should be able to access the website via the domain name then. I’ve also had it where I’ve needed to have an internal DNS server with a local record so that your clients access the server internally instead of reaching your server via an external record. Then I would have DHCP tell local machines what DHS server to use, but try the configs first and see if that will help

I entered my domain and IP in the trusted domains.

And you edited your apache configs too? And you also pointed your domain name to your IP address with the domain registrar? If you did all of those it should work

I tried several things in the Apache config file
apache.conf, is there another config to edit?

I’ll post my config files in the evening, maybe that will help!

/var/www/html/nextcloud/config/config.php

<?php
$CONFIG = array (
  'instanceid' => 'ocvg3k9rp9bs',
  'passwordsalt' => 'tI3Qii1R4UvjeJ8YzGw7/RksET4LZ4',
  'secret' => 'CYkb/6+6FD+eZiwLce++h5Yt9Ayf0EVuR65WbMl1sAjrqK5x',
  'trusted_domains' =>
  array (
    0 => '10.0.0.1',
    1 => '193.XXX.XXX.XXX',
    2 => 'www.exampledomain.at'
  ),
  'datadirectory' => '/sdfit/nextcloud/data',
  'overwrite.cli.url' => 'http://10.0.0.1/nextcloud',
  'dbtype' => 'sqlite3',
  'version' => '12.0.3.3',
  'installed' => true,
);

/etc/apache2/apache2.conf (outtake)

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

#<Directory /srv/>
#       Options Indexes FollowSymLinks
#       AllowOverride None
#       Require all granted
#</Directory>




# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
        Require all granted
</FilesMatch>

/var/www/html/nextcloud/.htaccess

<IfModule mod_headers.c>
  <IfModule mod_setenvif.c>
    <IfModule mod_fcgid.c>
       SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
       RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
    </IfModule>
    <IfModule mod_proxy_fcgi.c>
       SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1
    </IfModule>
  </IfModule>

  <IfModule mod_env.c>
    # Add security and privacy related headers
    Header set X-Content-Type-Options "nosniff"
    Header set X-XSS-Protection "1; mode=block"
    Header set X-Robots-Tag "none"
    Header set X-Download-Options "noopen"
    Header set X-Permitted-Cross-Domain-Policies "none"
    SetEnv modHeadersAvailable true
  </IfModule>

  # Add cache control for static resources
  <FilesMatch "\.(css|js|svg|gif)$">
    Header set Cache-Control "max-age=15778463"
  </FilesMatch>

  # Let browsers cache WOFF files for a week
  <FilesMatch "\.woff$">
    Header set Cache-Control "max-age=604800"
  </FilesMatch>
</IfModule>
<IfModule mod_php5.c>
  php_value upload_max_filesize 4G
  php_value post_max_size 4G
  php_value memory_limit 4G
  php_value mbstring.func_overload 0
  php_value always_populate_raw_post_data -1
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
<IfModule mod_php7.c>
  php_value upload_max_filesize 511M
  php_value post_max_size 511M
  php_value memory_limit 512M
  php_value mbstring.func_overload 0
  php_value mbstring.func_overload 0
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTP_USER_AGENT}  DavClnt
  RewriteRule ^$         /remote.php/webdav/          [L,R=302]
  RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  RewriteRule ^\.well-known/host-meta /public.php?service=host-meta [QSA,L]
  RewriteRule ^\.well-known/host-meta\.json /public.php?service=host-meta-json [QSA,L]
  RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
  RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
  RewriteRule ^remote/(.*) remote.php [QSA,L]
  RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
  RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/.*
  RewriteRule ^(?:\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]
  RewriteCond %{HTTP_HOST} ^193\.XXX\.XXX\.XXX$
  RewriteRule ^(.*)$ www.exampledomain.at/$1 [L,R=301]
</IfModule>
<IfModule mod_mime.c>
  AddType image/svg+xml svg svgz
  AddEncoding gzip svgz
</IfModule>
<IfModule mod_dir.c>
 DirectoryIndex index.php index.html
</IfModule>
AddDefaultCharset utf-8
Options -Indexes
<IfModule pagespeed_module>
  ModPagespeed Off
</IfModule>

neither editing virtual hosts, nor making a rewrite cond/rule helped.

Any help? Nobody?

You already postet the answer here :slight_smile:

‘overwrite.cli.url’ => ‘http://10.0.0.1/nextcloud’,

Change according to you external domain to

‘overwrite.cli.url’ => ‘http://myprivatecloud.at/nextcloud’,

and you’re good to go.

Thanks, I will try as soon as possible :wink:

didn’t help either :unamused:

i also entered an A record for my IP…

I don’t exactly know what you are messing with - but there are only three things necessary.

  1. DNS-Resolution domainname -> IP (which is working as i understood)
  2. Portforward 80/443 -> Nextcloud-Server (80 for letsancrypt, else not really needed)
  3. virtual host for nextcloud site either with *:443/80 or domainname:443/80

After that nextcloud is working and resolves its domain with what was entered in

‘overwrite.cli.url’ => ‘http://myprivatecloud.at/nextcloud’,

Dumb question - but did you restart Apache/Nginx after the change?

service apache2 restart

Else normal restart works too.