1

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.

4
  • 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. Jun 27, 2021 at 10:53
  • 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).
    – FedKad
    Jun 27, 2021 at 11:07
  • This local DNS server that you mentioned, is set up on the router or on the server?
    – yaylitzis
    Jun 27, 2021 at 11:10
  • 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 local.mydomain.com
    – FedKad
    Jun 27, 2021 at 11:21

1 Answer 1

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .