Score:1

Domain name isn't available on local network, but outside it is!

au flag

In our local network we have an Ubuntu Server 20.4, where it hosts a web application. I configured my router and the DNS of the domain, I installed Lets'Encrypt certificate and I have succeed that https://mydomain.com to show my web application.

My issue is that when I try to see the domain https://mydomain.com from inside the local network, the browser responds that `This site can’t be reached, but when I am connected outside the site is visible.

I have to apply a new setting in the Ubuntu Server or this is a router's configuration matter?

One solution...

I edited hosts file in my pc (C:\Windows\System32\Drivers\etc\hosts) adding a record

192.168.0.100 mydomain.com

and the site is visible now, but I would like to know how can I apply a setting to Ubuntu server.

Edit 1 If I run nslookup mydomain.com from the command line of Windows I get:

Server:  one.one.one.one
Address:  1.1.1.1

Non-authoritative answer:
Name:    mydomain.con
Address:  My_External_IP

Both Ubuntu Server and my PC are on the same subnet. I have added some port forwards (80, 443) to the router, in order to make public the server.

Vijay Prema avatar
jp flag
Please explain how your local network is set up (that the server is part of). This could be a NAT issue, or hairpin/loopback issue, but we cant tell without any info about your network.
FedKad avatar
cn flag
Local IPs (like 192.168...) will be different from WAN IPs. You will need a method (a local DNS server) that serves the local IPs, while your Internet DNS server will serve the Internet IPs. Another solution would be to edit the `hosts` file of each potential client (as you already did).
yaylitzis avatar
au flag
This local DNS server that you mentioned, is set up on the router or on the server?
FedKad avatar
cn flag
Your router probably will not have such a function. But if you have a wildcard LetsEncrypt certificate, you can do something like this on your Internet DNS server: `mydomain.com your_external_ip` as already done. Add a record like this `local.mydomain.com 192.168.0.100` and access your web server internally using the name https://local.mydomain.com
Score:0
cn flag

Well the "problem" is that your Windows machine (and other machines on your network) resolves to the domain name to a public IP address, which is different than 192.168.0.100... Thus the routing is different. When you try to access 192.168.0.100 the traffic stays inside your LAN. If you use a public IP address then your traffic will transit on the Internet and come back to you through the router.

So indeed you should set up port forwarding on your router, so that incoming requests to ports 80 & 443 are forwarded to the local address of the server, that is 192.168.0.100 in your example.

If you had your own DNS resolver in your LAN, then you could simply configure that domain (the "zone") locally to return a private IP address instead, only for local users. See split-horizon DNS.

Editing the hosts file may be acceptable for testing, short-term usage, if you don't have many clients to maintain. Otherwise my suggestion would be to set up a local DNS resolver (and forwarder) for your LAN. Example: dnsmasq.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.