Search code examples
network-programmingroutercaddy

Access server in local network through domain


i have problem with access to server with domains.

Test url: testpage.example.com.

Server is in local network with port fowarding (80, 443), configured as web server using caddy server as reverse proxy.

Case 1 (using Asus router): Connected on local network behind router. Server is in the same network as my computer. Everything works like a charm in and out of my network.

Case 2 (using internet provider router): Connected on local network behind router. Can't access server with domain. Works with direct IP. Outside network, works as in case 1.

I used same server.

Does anyone know why this problem occured? How can i solve it?

Thanks, David


Solution

  • Two options I can think of:

    1. You could add a record to whatever DNS server you're using in Case 2.
    2. You could write a short script that runs whenever you change network connections to modify your hosts file accordingly.