Using Dnsmasq for local development on OS X
passingcuriosity.com
passingcuriosity.com
Edit: Invoker doesn't seem to support the pow use case -- local configuration, not global. Inspired by the topic, I found https://github.com/riywo/anypow , which has a wrapper for non-rack applications, and can be used to make pow play nice with Procfiles.
Recently I've started using Vagrant for more complex sites that require custom server software, or are based outside the traditional LAMP stack, but a Dnsmasq based setup on my mac is still my favorite for most sites.
This lets you boot up your Rails app normally, or via Procfiles, instead of booting up through all the pow.cx magic that can be a real pain to debug.
It handles the .dev DNS resolution, and also supports hosting domains that you map through /etc/hosts (ex: foo.company.com if you need to share cookies with a SSO server, but don't want all of company.com directed to your local machine)
It is much easier to configure than Apache vhosts for distributing traffic based on host name:
* symlink to Rack app for Ruby support. Name of symlink becomes hostname
* create a directory and symlink Public for static HTML. Directory name is hostname
* as sibling said, put port # in text file to proxy traffic to another process. File name is hostname
I use Anvil for Mac to do some of my Pow management.
I'm also using Apache to do SSL termination and proxy to Pow, as well as host some other stuff. But Pow is so easy to use for both static sites and proxying to another web server, I prefer it.
I like to setup our designers with this, but have found it useful myself from time to time.
I am about to loop back around to a mobile project and I am hoping I can use it to tests my mobile app interactions with my local development box more easily than I have been able to in the past.
On the goal of having unlimited easy to configure real domains that point to locahost, another service of interst is localtest.me [1]. This offers *.localtest.me -> 127.0.0.1
Off: proxies no HTTP requests.
Manual: proxies all HTTP requests through a proxy server at the specified host and port.
Auto: uses JavaScript code hosted on a Web server at a specified (unproxied) URL to determine how HTTP requests get proxied. Assuming your proxy server is at host.example.com:8080, specifying a URL pointing to a file containing
function FindProxyForURL(url, host) {
if (shExpMatch(host, "*.vm.example.com")) {
return "PROXY host.example.com:8080";
} else {
return "DIRECT";
}
}
should proxy only HTTP requests whose URLs point to hosts in the .vm.example.com subdomain through your proxy server.Disclaimer: I haven't tested any of this, and everything I know about proxy auto-configuration comes from skimming the Wikipedia page[1] just now.
by using something to edit the hosts file you'd have to edit it every time (can't do wildcards on hosts file, so it needs editing every time)
I've never tried it on OSX, but this guide seems to cover dnsmasq + nginx virtualhosts :-)
http://zaiste.net/2013/03/serving_apps_locally_with_nginx_an...
http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html
I just create a new directory, and with the wildcard DNS, I have a new dev site.
…how is this different from editing /etc/hosts?
1) You don't have to add new .dev hosts to /etc/hosts repeatedly. Once you're setup, all .dev is local
2) /etc/hosts doesn't support wildcards, so dnsmasq is great with apps that have many or randomized subdomains.
You can then combine this with xip.io and be able to share your dev site with others.