Gazza
Gazza

Reputation: 3141

Local domain names for development on Mac OS

We have several Rails apps that run within a Vagrant box (port forwarding already set up). How can we get subdomain-ready development domain names working for these apps?

We don't like the hosts file approach since:

Upvotes: 2

Views: 2249

Answers (2)

mc0e
mc0e

Reputation: 2820

If all your stuff is under one parent domain, you may be able to do what you want with a DNS wildcard.

*.vagrant.mydomain.com.    CNAME    vagrant.mydomain.com.

You may even want to point something like the above to a private network address which each of your developers has set up as a host-only network on their local virtualbox setup. You can set up the network and the host ip from your Vagrantfile, so everyone runs their dev environment at the same location with no special effort, so the same DNS entry, which can be served outside the dev box works for everyone.

If You're running a Bind9 DNS server then you could specify something like the following in order to cater for a bunch of vagrant boxes on a local 192.168.192.0/24 network on each dev's system:

$ORIGIN vagrant.mydomain.com.
$GENERATE 10-99  *.$  A  192.168.192.$

So for example foo.27.vagrant.mydomain.com will point to 192.168.192.27, for any foo.

(not actually tested code here. correct if it needs it).

Upvotes: 2

lukerandall
lukerandall

Reputation: 2212

This sounds like a good fit for Pow. Pow is generally used for running apps directly, but can also port proxy. Additionally, it handles domains (including wildcard subdomains) for you automatically.

Quoting from the manual:

2.1.4 Port Proxying

Pow's port proxying feature lets you route all web traffic on a particular hostname to another port on your computer. To use it, just create a file in ~/.pow (instead of a symlink) with the destination port number as its contents.

For example, to forward all traffic for http://proxiedapp.dev/ to port 8080:

$ echo 8080 > ~/.pow/proxiedapp

You can also use port proxying to access web apps written for other runtimes such as Python or Node.js. Remember that services behind the proxy won't automatically be started or stopped like Rack apps.

Upvotes: 2

Related Questions