How to auto configure local domain to point at docker container - macos

My aim is to have a self-contained repository that a user/developer can pull down (on a mac), type docker-compose up -d and have a working development environment via a friendly url like http://myproject.dev/
I have my docker images set up as needed but the local domain is where i've come unstuck. I know this is a bit outside of Docker, as this is a host system thing. But i'm really looking for a way to achieve this without requiring the user to install local apps or make various local system config changes.
Is this something that is achievable, or am i barking up the wrong tree?
**Sorry guys, i missed out some important info. I ideally want to avoid pointing to localhost as this would cause conflicts if/when running multiple projects. So i guess we would need to point to the containers IP, so host entries would need to be dynamic. murky dns waters indeed

I know you said:
... or make various local system config changes.
But if you can lift that requirement, the one change you need to make for local macOS systems would be an addition to /etc/resolver/dev. Then, you can run a DNS server to your docker-compose.yml that automatically adds entries for the services such as https://github.com/ruudud/devdns (specifically, the https://github.com/ruudud/devdns#host-machine--containers bit).

Point a real world DNS record that all your developers can lookup to 127.0.0.1. So myproject.existing.tld would point to 127.0.0.1.
An example is vmware's could application platform:
→ dig +noall +answer vcap.me
vcap.me. 3412 IN A 127.0.0.1
→ dig +noall +answer whatever.vcap.me
vcap.me. 3412 IN A 127.0.0.1
Otherwise your treading into the murky waters of advertising services via
mDNS (or LLMNR) and Zeroconf.

Related

I don't have fixed IP address, how can I let others access my database?

I run Memgraph Platform on my laptop inside Docker container. When I'm at the office my colleague can access it, but when I work from home he can not get to the database. I don't have fixed IP address, and my ISP doesn't allow me to do port forwarding and dynamic DNS also doesn't work for me. What can I do to make my database accessible to others?
Try to follow the advice given by #Martheen. I have experience with running Tailscale for this purpose and it works.
I don't know why you can't deploy it to some server (if there are regulation issues or company policies in question) but if it is not any of those maybe you could use Memgraph Cloud and host your data. That way you would be sure that everyone with the right credentials could access your data. But it all depends on your setup and usage scenario. Since you are using Docker I presume that you have all of your environment configured right the way that you want on your laptop.

How to add a hostname to the LAN so that a Ruby web server, such as WEBrick can serve off that hostname?

We can use Ruby and WEBrick to start a local web server, just by
ruby -run -e httpd -- -p 8080 .
I have seen some iPhone / iPad app being able to add a hostname of http://awesome.local:1234 on the LAN, so a local Mac, and other computers can connect to it. How can we do this using Ruby, adding the hostname and add it together, if possible, with WEBrick?
It is not possible to do anything with Ruby to do this, because this is not Ruby's problem. Computers deal with translation of host names to IP addresses in two different ways: hosts file and a DNS query.
hosts file is a way to tell a specific computer what addresses it knows about. You edit the file, put in what name maps to what IP address, and when that computer makes a request to one of those names, it knows who to contact. Since you need to have the record in the client's computer, there is nothing you can do on the server to affect it, which is why no amount of fiddling with Ruby or WEBrick will help. Also, iPhones don't have a hosts file you can edit.
When a computer does not know a name, it asks someone who does. This someone is a DNS server, a sort of smart Yellow Pages for computers. Your computer has a DNS server it is configured to work with; if it does not know, it will ask other DNS servers for the information. Notably, the router of your LAN almost certainly has DNS functionality.
Thus, the normal way to do what you want to is to tell your router which address it should tell everyone when asked about awesome.local. How to do this is both off-topic for Stack Overflow (as it is not a programming problem; you could ask on SuperUser), and impossible to answer without knowing the exact make and model of your router.
EDIT: Given that your example involves an iOS device, there is another answer: : Apple devices use Bonjour to yell their own configuration data at each other. It's not the app doing it, it is iOS. You can install Bonjour on most other operating systems. There is also a Ruby gem that implements Bonjour protocol, dnssd. I have not worked with it, so I can't tell you whether or not it will solve your problem.

Performance boost with DNS caching?

IN SHORT:
How would one create a local DNS cache on a linux system (ubuntu) so that common queries can run faster, and is it then possible to purge it?
The cache should be populated upon first-queries, not created by hand.
BACKGROUND:
There's a web server up in the cloud which makes connections to itself since the database is currently on the same (virtual)machine. To make it easier for future expansion where the database will be on another server, I've simply pointed the webserver at an address like database.example.com and set the DNS record to 127.0.0.1. The plan is that I can then simply change the DNS record once everything's migrated over. This might seem overkill with just web and database, but there will be other types of servers too (redis, node.js, etc.)
The problem is that when I use the hostname version, it is going very slow (5-10 seconds for session_start). When I use the IP address (i.e. 127.0.0.1), it is very fast (a couple milliseconds).
It seems clear to me that the problem is in DNS, and I believe local caching is a fine solution since it will allow me to manage it all in one place, rather than having to step through the different parts of the system and change configuration.
Install dnsmasq
apt-get install dnsmasq
Lock it down to only localhost add the following to /etc/dnsmasq.conf
listen-address=127.0.0.1
start your service and verify that it is running
service dnsmasq start
dig www.google.com #127.0.0.1
Edit /etc/resolv.conf add the following as your first line
nameserver 127.0.0.1
And remove options rotate if present.
Note you may have some scripts automatically rewriting / changing /etc/resolv.conf it which case you'll have to change those as well (ie dhclient or /etc/network/interfaces)

amazon ec2 - name server issue

i have created new instance in amazon ec2, and assigned the elastic ip for instance. But i need to know how to get ip for name server (ns1.abc.com, ns2,abc.com).
I have installed whm in amazon instance. Only domain cannot point to the correct name server. That is because ip cannot load.
Now, my problem is that how i get new ip. Can i add another two elastic ip in amazon? But i configured two elastic ip for name server in dns zone within whm. The name server is not working. And i cannot open the elastic ip in browser. I am confuse for it. Please anyone help me.
There are lots of things that can go wrong here. I'll try to troubleshoot step by-step:
I'll assume the goal is "You want to type 'whm.foo.com' and see your WHM"
1) Go to your domain registrar and make an entry that points "whm.foo.com" to your EIP. (Depending on what you want, maybe you should setup a "*.foo.com" wildcard for that EIP.
2) Test that step #1 worked by typing "ping whm.foo.com" or "dig whm.foo.com" (one linux/mac, not sure about Windows). This should return your EIP. If not, go back to step 1.
3) Check that WMH is acually running. Read the docs to find what port it's running on. (Usually 2083, or 2082 for insecure access)
On your instance, run "curl -v localhost:2083" (or whatever port. It should return a login screen. If it says "couldn't connect to host", then you have the wrong port or it's not running.
4) run "netstat -na | grep :2083" (or whatever port). It should say "0.0.0.0:*". If it says "127.0.0.1:*", then you need to configure it to allow outside access.
5) Make sure your WHM port is enabled in the AWS firewall. Go to the AWS control panel and find the security group for your box. Make sure that port is allowed. Ideally, you'd only add your personal IP instead of opening it up to the world. (If there is a bug in WHM, people will scan all IPs trying to exploit it. They can't exploit your server if the AWS firewall denies them access.)
6) Now type "https://whm.foo.com:2083" (or whatever port) in your browser. (or http://whm.foo.com:2082 for insecure access). It should work!
i need to know how to get ip for name server (ns1.abc.com, ns2,abc.com).
As rdrey said, you need to go to your DNS provider (most registrars also do DNS) and tell them what boxes should point to your EIP.
That is because ip cannot load.
There is no such thing as "ip cannot load". Either "DNS is giving the wrong IP" or "some IP operations (TCP ports) were blocked by a firewall somewhere".
Now, my problem is that how i get new ip
I don't think that should be your goal. You can easily change EIPs, but it won't fix the problem. Nothing works unless everything in between is set up correctly. The goal should be understanding all the steps in the process and verifying that each step was done correctly.
OK, you have two options here:
Use the DNS servers provided by your Domain Registrar OR
Use AWS Route53 to let Amazon provide DNS services for you.
Option 1:
You bought your domain name from a registrar, like one of these: http://lifehacker.com/5683682/five-best-domain-name-registrars
Most, if not all, registrars run a free DNS service for their customers. You should be able to log into some kind of management console and set your domain's DNS zone entries to point at your AWS EIP. (I am using gandi.net and used to use godaddy. You simply leave the DNS Servers as they are and set your AWS EIP as the 'A' record.)
Option 2:
Go to https://console.aws.amazon.com/route53/home and follow instructions. I haven't read up on Route53's pricing, so this option might not be free.
---- EDIT:
Some more help:
The site you've linked to (http://www.intodns.com/xantec.com.sg) states that you've used your EIP (54.251.169.7) as the nameserver for the domain. You don't want that. You're running a cPanel installation, NOT a DNS nameserver.
Put 54.251.169.7 as your site's A record. (Sometimes called the www field.) Remove it from the NS fields and put ns3.thesimpledns.com & ns4.thesimpledns.com into those.

How do I get bind to use the DHCP dns for lookup?

I've got XAMPP setup on my laptop (OSX 10.6) for dev, and I wanted to use VirtualDocumentRoot so that I could do *.localhost and it would automap to the folder under my sites directory. I've got this all set up fine, and it works great, but when I got to work today, I found an issue with the way our LAN handles DNS.
Long story short, instead of checking the LAN DNS server for local domains, it goes out to the root. Is there a way to get bind to check the DHCP supplied DNS server for addresses it's not responsible for? Or alternatively, is there a way to get my os to use the DHCP DNS server first, and then fall back to the local with minimal performance hit?
Thanks!
I'm using Linux Arch, but as MacOSX is based on some *nix system - may this ideas helps you:
Take a look at the file /etc/resolv.conf. In my setup this file is automatically generated by NetworkManager.
This document writes about ways to update /etc/resolv.conf when dhcpcd, NetworkManager or dhclient is used: https://wiki.archlinux.org/index.php/Dnsmasq#DHCP_Setup
In this way you do just prepend the local dns before the dhcp's dns (or static if you're switching to a static configuration). Make sure you remove all forwarders from your dns-server.
If macos does not use them, may this workaround gives you a hint, even if it's very limited:
Add a global name-server (like google's one 8.8.8.8) to your dns-server's list of forwarders.

Resources