snippetdockerMinor
How to locally resolve host name starting with variable slug?
Viewed 0 times
startingwithlocallyresolvenamehostslughowvariable
Problem
An app, running on my laptop in development mode, comprises several Docker containers, one of which runs a Django web app.
This web app expects to receive HTTP requests using a hostname with a variable leading part, e.g. "test-account.survey.com", in which 'test-account' is a slug representing a particular account, and the remaining string 'survey.com' is fixed.
Now I know this can be resolved in a Live environment, involving external HTTP requests, by using wildcard DNS servers [ https://en.wikipedia.org/wiki/Wildcard_DNS_record ].
But I'd like to set up and configure on my laptop a local DNS server for the sole purpose of forwarding hostnames as above to a fixed IP address, e.g. 127.0.0.1 and "passing through" any other hostnames.
Any recommendations? Thanks in anticipation.
P.S. The DNS server must support Windows 10 and Mac OS.
This web app expects to receive HTTP requests using a hostname with a variable leading part, e.g. "test-account.survey.com", in which 'test-account' is a slug representing a particular account, and the remaining string 'survey.com' is fixed.
Now I know this can be resolved in a Live environment, involving external HTTP requests, by using wildcard DNS servers [ https://en.wikipedia.org/wiki/Wildcard_DNS_record ].
But I'd like to set up and configure on my laptop a local DNS server for the sole purpose of forwarding hostnames as above to a fixed IP address, e.g. 127.0.0.1 and "passing through" any other hostnames.
Any recommendations? Thanks in anticipation.
P.S. The DNS server must support Windows 10 and Mac OS.
Solution
People often use dnsmasq for this. You can wildcard sub-domains like this fairly easily for local testing using it.
Here's an example - https://qiita.com/bmj0114/items/9c24d863bcab1a634503 but there are plenty online.
Here's an example - https://qiita.com/bmj0114/items/9c24d863bcab1a634503 but there are plenty online.
Context
StackExchange DevOps Q#11396, answer score: 1
Revisions (0)
No revisions yet.