mirror of
https://github.com/danbee/danbarber.me.hugo.git
synced 2025-03-04 08:59:18 +00:00
Compare commits
No commits in common. "bd10013aa60a1582df55e8410891cae30cd8ec77" and "3ed847264ae7e63df3bfeb7b199f1ba63856e1dd" have entirely different histories.
bd10013aa6
...
3ed847264a
@ -1,81 +0,0 @@
|
||||
---
|
||||
title: Setting up a local resolver on macOS
|
||||
date: '2020-01-04T02:30:25+00:00'
|
||||
layout: micropost
|
||||
categories:
|
||||
- web
|
||||
- web development
|
||||
- dns
|
||||
- internet
|
||||
---
|
||||
|
||||
For a good number of years I was using Basecamp's Pow for local web
|
||||
development and one of my favourite features was the in built local DNS
|
||||
resolver that meant that `*.dev` would resolve to `127.0.0.1`. This mean
|
||||
that I had a unique hostname for every site I was building and running
|
||||
locally which I have found incredibly useful.
|
||||
|
||||
Unfortunately Pow no longer sees active development (the GitHub repo has
|
||||
been archived) so I wanted to see if I could set up the same kind of
|
||||
local resolver on my Mac without using it.
|
||||
|
||||
It turned out to be pretty straightforward!
|
||||
|
||||
Note: We're using `.localhost` instead of `.dev` because Google own the
|
||||
`.dev` TLD and in 2017 they added an HSTS rule to Chromium that forces
|
||||
any `.dev` domain to use HTTPS. As you can imagine, this is not ideal
|
||||
for local development so web developers everywhere had to adjust their
|
||||
setups.
|
||||
|
||||
First of all we need to install Dnsmasq. This will handle the local name
|
||||
resolution. If you're using Homebrew this is dead simple:
|
||||
|
||||
$ brew install dnsmasq
|
||||
|
||||
Then we need to configure it to resolve any domain name that ends in
|
||||
`.localhost` to resolve to `127.0.0.1`.
|
||||
|
||||
Uncomment the following line:
|
||||
|
||||
# /usr/local/etc/dnsmasq.conf
|
||||
conf-dir=/usr/local/etc/dnsmasq.d
|
||||
|
||||
Add the following file to the Dnsmasq configuration directory:
|
||||
|
||||
# /usr/local/etc/dnsmasq.d/localhost
|
||||
address=/.localhost/127.0.0.1
|
||||
|
||||
Start `dnsmasq` as root (It needs to be running as root to be able to
|
||||
bind to port 53):
|
||||
|
||||
$ sudo brew services start dnsmasq
|
||||
|
||||
Next we need to tell macOS about the local resolver.
|
||||
|
||||
Add the following file (You will need to do this as `root`):
|
||||
|
||||
# /etc/resolver/localhost
|
||||
nameserver 127.0.0.1
|
||||
domain localhost
|
||||
search_order 1
|
||||
|
||||
And voila! Any domain ending in `.localhost` should now resolve to
|
||||
`127.0.0.1`. We can test this with a ping:
|
||||
|
||||
$ ping foobar.localhost
|
||||
PING foobar.localhost (127.0.0.1): 56 data bytes
|
||||
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.122 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.262 ms
|
||||
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.281 ms
|
||||
|
||||
## So why is this useful?
|
||||
|
||||
That's a very good question! Here's some of the reasons I've found:
|
||||
|
||||
1. If you're developing an app that relies on a number of small
|
||||
services it can be useful to differentiate them by domain.
|
||||
2. It makes OAuth callback URL's more readable.
|
||||
3. It's useful for external services that require a domain name to
|
||||
authenticate. A good example of this is font services such as
|
||||
Typekit or Hoefler & Co.
|
||||
4. It just looks pretty up there in the URL bar!
|
||||
@ -1,56 +0,0 @@
|
||||
==================================================================
|
||||
https://keybase.io/danbarber
|
||||
--------------------------------------------------------------------
|
||||
|
||||
I hereby claim:
|
||||
|
||||
* I am an admin of https://danbarber.me
|
||||
* I am danbarber (https://keybase.io/danbarber) on keybase.
|
||||
* I have a public key ASCgDII3lQFbtjX0L0sQAkZxOoIN3ohOmCyoaXJ6vKqFUQo
|
||||
|
||||
To do so, I am signing this object:
|
||||
|
||||
{
|
||||
"body": {
|
||||
"key": {
|
||||
"eldest_kid": "010128e434c41edb2911b1d194aa081a9c8ac71ec00bbf260e7ab50b97785ab681150a",
|
||||
"host": "keybase.io",
|
||||
"kid": "0120a00c823795015bb635f42f4b100246713a820dde884e982ca869727abcaa85510a",
|
||||
"uid": "1f5d09278c7c1146ffceb986aa9f4700",
|
||||
"username": "danbarber"
|
||||
},
|
||||
"merkle_root": {
|
||||
"ctime": 1575425150,
|
||||
"hash": "797e396181e76568f7dded5efb2148af90c866777698274e3f92006f03af89c12e10aaab71c48d67df4c737e22bc5db57068467565611e7074f0d21fd7ae17b8",
|
||||
"hash_meta": "36d725cfb063d2f472b8df7363d2d620c6c4080913f03cfd8294f9c9d03d100f",
|
||||
"seqno": 12074018
|
||||
},
|
||||
"service": {
|
||||
"entropy": "3vjbKErNWNa4EjRap4YZIVaz",
|
||||
"hostname": "danbarber.me",
|
||||
"protocol": "https:"
|
||||
},
|
||||
"type": "web_service_binding",
|
||||
"version": 2
|
||||
},
|
||||
"client": {
|
||||
"name": "keybase.io go client",
|
||||
"version": "5.0.0"
|
||||
},
|
||||
"ctime": 1575425161,
|
||||
"expire_in": 504576000,
|
||||
"prev": "78852a402e3ce95df31deab1af9be72d91699cb3afd46fbcfcfc30c275ad6b58",
|
||||
"seqno": 38,
|
||||
"tag": "signature"
|
||||
}
|
||||
|
||||
which yields the signature:
|
||||
|
||||
hKRib2R5hqhkZXRhY2hlZMOpaGFzaF90eXBlCqNrZXnEIwEgoAyCN5UBW7Y19C9LEAJGcTqCDd6ITpgsqGlyeryqhVEKp3BheWxvYWTESpcCJsQgeIUqQC486V3zHeqxr5vnLZFpnLOv1G+8/PwwwnWta1jEIC3j85NhQdhE786L/4P2sLUPhKTQ9iei/ALO1L2FQTjvAgHCo3NpZ8RAVPbw0v82p8nRb/z8gx8hMp4sD97fYbB9Bysc2Giu1N3L4LLGSAv8LbNqR4QwdyhD0Lm+A0/0ufyZQOPTeDcVBqhzaWdfdHlwZSCkaGFzaIKkdHlwZQildmFsdWXEIFwmQI30xuk6aIokJGDkCxCmlGdNFPfk+aMgVqQnx6sco3RhZ80CAqd2ZXJzaW9uAQ==
|
||||
|
||||
And finally, I am proving ownership of this host by posting or
|
||||
appending to this document.
|
||||
|
||||
View my publicly-auditable identity here: https://keybase.io/danbarber
|
||||
|
||||
==================================================================
|
||||
Loading…
Reference in New Issue
Block a user