Skip to content

Instantly share code, notes, and snippets.

@juliangruber
Last active December 27, 2015 16:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save juliangruber/7356625 to your computer and use it in GitHub Desktop.
Save juliangruber/7356625 to your computer and use it in GitHub Desktop.
setup custom local.host

So you might have set up dnsmasq with this tutorial but then you notice that you can't set cookies to subdomains of localhost or for all of localhost's subdomains (see why).

So we set up a custom "localhost", that I'll call local.host, but you can pick whatever you want, as long as it contains at least one dot. Just adapt the first two commands.

$ # add to hosts list
$ sudo echo "127.0.0.1 local.host" >> /private/etc/hosts
$ # tell your dns server about it
$ echo "address=/local.host/127.0.0.1" >> /usr/local/etc/dnsmasq.conf
$ # restart your dns server
$ sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist

Now when you want to access local.host, in most browsers you have to prepend http:// otherwise they go search for it with your default search provider :(

So: http://local.host/ and you can set cookies on subdomains (like my.super.shiny.local.host) as you please :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment