How to resolve if you cannot access nextcloud by domain name ?

Reading Time: 3 minutes

I saw error with “Access through an un trusted domain” when I accessed with domain name…
I saw router page when I accessed nextcloud from home Wi-Fi…

You will find solution after reading this post.

As a precondition, domain name setting has been done.
If you have not set it, please refer to this page.

Reviewing Nextcloud settings

The nextcloud configuration file has a list of trusted domain names, so let’s add them.

yasu@raspberrypi:~ $ sudo nvim /var/www/html/nextcloud/config/config.php

  array (
    0 => '',              # <- This is already there
    1 => '',      # <- Add it
    2 => '',  # <- Add it

That’s it.

How to resolve issue of going router page when you access it with domain name

When I accessed in my environment, I saw router setting page like this:
(Sorry only Japanese page)

To resolve this there needs to convert from to local IP address(not global IP address) because normally is converted to global IP address which is IP address of rounter itself, hence rounter page is displayed.

To resolve this I will do it.
– Set up a DNS server
– Configure DNS server to resove to local IP address

Set up a DNS server – dnsmasq –

There’s already Raspberry Pi 4, so let’s put a DNS server in there!
dnsmasq is very easy to setup, configure.

# Install dnsmasq
pi@raspberrypi:~ $ sudo apt install dnsmasq

# Setup dnsmasq resolves only name and otherwise delegates to a regular DNS server
pi@raspberrypi:~ $ sudo nvim /etc/hosts

# Add the following two lines to the end of /etc/hosts
# Www No, both domain names

# Restart dnsmasq
pi@raspberrypi:~ $ sudo systemctl restart dnsmasq

Change router settings

Next is the settings on the router side.
Since the router is usually a DNS server of home Wi-Fi, so add item to list for forwarding DNS query of to Raspberry Pi 4.

In my case I am using an RS-500KI, and there was a setting here.
– top page(トップページ) -> Advanced(詳細設定) -> DNS settings(DNS設定)

In entry 1 of local domain query table(ローカルドメイン問合せテーブル), query request about will be transferred to DNS server you specified.
DNS server should be Raspberry Pi 4.

RS-500KI requires only IPv6 address for DNS server address.
Let’s check the IPv6 address of Raspberry Pi 4.

pi@raspberrypi:~ $ ifconfig
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet netmask broadcast
inet6 fe80::6637:6bde:4579:381b prefixlen 64 scopeid 0x20 <link>
inet6 2408:211:b0:dd00:ffef:f44f:9e78:bad7 prefixlen 64 scopeid 0x0 <global>
ether dc:a6:32:bf:f5:d4 txqueuelen 1000 (Ethernet)
RX packets 126 bytes 17554 (17.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 81 bytes 12776 (12.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0</global> </UP,BROADCAST,RUNNING,MULTICAST>

The string starting from 2408 in this is IPv6.
Input and set it on the router settings.

I tried to access it for confirmation.
It’s working as expected!

However, when I accessed here, the screen was displayed as http instead of https.

Change apache2 settings to solve it.

pi@raspberrypi:~ $ sudo nvim /etc/apache2/sites-enabled/000-default.conf

# Contents of 000-default.conf below
<VirtualHost *:80="">
RewriteEngine on
RewriteCond %{SERVER_NAME}
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
# ↓Add these two line
RewriteCond %{SERVER_NAME}
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI[END,NE,R=permanent]} 

# apache2 reboot
pi@raspberrypi:~ $ sudo systemctl restart apache2 is now also converted to https.


How was it?

It takes time and effort to become an environment that can be used in its way …

I never give up to setup convenient environment!