Problem description

I am developing a web application with a React Frontend and PHP backend. For crossorigin and cookie Reasons I need to host the frontend on the same domain namespace as the backend. I need to access a deployed version of my backend with my local computer which hosts the fronend.

Previous solution

(Working only locally not on devices on the network)

For my Mac, I got it working reliably like this:


...   local.mydomain.com
::1         local.mydomain.com

New Solution

(not yet working as expected)

I implemented a DNS server on my Synology (disabled my Macs host entries) and set it up in my local network router like this:

Name Type TTL Information
.local.mydomain.com NS 86400 ns.local.mydomain.com.
ns.local.mydomain.com A 86400 (local fixed IP of my computer)
anothersub.local.mydomain.com A 86400 (local fixed IP of my computer)

I also would like to instead of anothersub.local.mydomain.com use *.local.mydomain.com, however, when I did so, it always added a www to the local.mydomain.com on my iPhone like www.local.mydomain.com which does prevent my app from working properly. On my Mac on the other hand, it works as expected. (Update: It is not, I forgot to disable some hosts entries)

I am not sure if it is some iPhone behavior but it seems like the iPhone always calls both local.mydomain.com and www.local.mydomain.com whenever I enter local.mydomain.com. Generally my iPhone can access my app on my computer also on www.local.mydomain.com, but it just doesn't work as expected.

mydomain.com is a registered domain on the web, while I haven't registered the local.mydomain.com subdomain on my webserver. I suspect, however, if my iPhone calls www.local.mydomain.com it will somehow land on my webserver and not my local dns, getting an answer but of course not a success.

Is there any entry I can add to my DNS list to forward any call to www.local.mydomain.com to local.mydomain.com?

Updated question: how do I get local.mydomain.com and not only anothersub.local.mydomain.com working?

  • 1
    Local DNS changes don't get read by many devices in the age of DNS over HTTPS (DoH). Can you make these DNS changes on a public DNS server rather than on a local DNS server? Commented May 13 at 14:55
  • I disabled iCloud Private Relay on my iPhone and it should do the job. anothersub.local.mydomain.com is working as expected, but just the local.mydomain.com is not Commented May 13 at 15:24
  • So @StephenOstermiller if I would figure out the correct DNS entries, could I just enter them on my webhoster site to forward any request to local.mydomain.com to a local IP? Would this work as long as I am within my network? Commented May 13 at 15:32
  • 1
    Yes that works. The problem may also have to do with which network your phone is connected to. How are you verifying that it is on the local network and not on the cell phone network? Commented May 13 at 15:45
  • 1
    If you are making the DNS changes on a public DNS server, I think you should remove the NS record for the local altogether. Commented May 13 at 17:15

1 Answer 1


So I found out I only had a NS entry but no A entry for my root subdomain. In order to get it work I needed to add an entry like this

Name Type TTL Information
local.mydomain.com A 86400 (local IP of my computer)

However, I also want to point out that it is required to disable DNS Rebind Protection in the Router and iCloud Private Relay on your devices in order to work.

The reason why it was working for www.local.mydomain.com was because I already had an entry like this before which I removed but I suppose was still cached on my device:

Name Type TTL Information
*.local.mydomain.com A 86400 (local IP of my computer)

So my device tried both with and without the www and with the www it had a success so it appended it.

Setup on Webserver

So I also finally managed to move my DNS setup to my webserver. This way I do not need to disable iCloud Private Relay. My setup looks like this. (I needed to wait for a while before it was synced to my DNS and worked)

Name Type TTL Information
local.mydomain.com A 86400 (local IP of my computer)
anothersub.local.mydomain.com A 86400 (local IP of my computer)

I might possibly manage to replace anothersub.local.mydomain.com with *.local.mydomain.com for wildcard subdomains but it is not really required for my use case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.