Skip to content

Instantly share code, notes, and snippets.

@davidguttman
Forked from juliangruber/gist:7356625
Created November 7, 2013 17:50
Show Gist options
  • Save davidguttman/7358845 to your computer and use it in GitHub Desktop.
Save davidguttman/7358845 to your computer and use it in GitHub Desktop.

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