Anchor is Pow-like DNS responder and port forwarding service. Unlike Pow, Anchor does not have a built-in webserver and won't launch web process for you. You have to run your own development webserver and Anchor will simply forward all requests from .dev domain to any port you defined.
Installing Anchor is still somewhat complex at its current state. If you feel advantageous enough, you may follow these instructions. Please make sure you have Python 2.6 (or higher) and pip installed on your system.
Anchor is targeted for Mac OS X but may also work with other UNIX-like systems (you have to use 127.0.0.1:29430 as a DNS server and forward port 80 to 29431).
Try it at your own risk.
-
pip install git+https://github.com/sirn/anchor.git -
Create
/etc/resolver/devwith following contents:nameserver 127.0.0.1 port 29430Pow users may have this file created, if you no longer use Pow you can delete it.
-
In your root directory create
/Library/LaunchDaemons/com.gridth.anchorconfig.plistwith following contents:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Label</key> <string>com.gridth.anchorconfig</string> <key>ProgramArguments</key> <array> <string>sh</string> <string>-c</string> <string>ipfw add fwd 127.0.0.1,29431 tcp from any to me dst-port 80 in && sysctl -w net.inet.ip.forwarding=1</string> </array> <key>UserName</key> <string>root</string> <key>RunAtLoad</key> <true /> </dict> </plist> -
In your home directory create
~/Library/LaunchAgents/com.gridth.anchor.plistwith following contents:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist> <dict> <key>Label</key> <string>com.gridth.anchor</string> <key>ProgramArguments</key> <array> <string>python</string> <string>-m</string> <string>anchor</string> </array> <key>KeepAlive</key> <true /> <key>RunAtLoad</key> <true /> </dict> </plist>You may want to change
<string>python</strong>if you're using VirtualEnv. -
Run
launchctl load -w /Library/LaunchDaemons/com.gridth.anchorconfig.plistandlaunchctl load -w ~/Library/LaunchAgents/com.gridth.anchor.plist.
Put a site configuration file in .anchor/ directory in your home directory. The configuration file must have at least [anchor] declared. For example:
[anchor]
aliases = www
port = 3000
[images]
directory = /srv/http/anchor/images/
Everything in anchor section are mapped to naked domain using filename as its domain: [anchor] section in mysite.conf is mapped to mysite.dev, for example. You may also create subdomain with a new section (in the example above images.mysite.dev will serve static contents from directory) or aliases using aliases directive.
Currently there are three directives available:
aliasesspace-separated list of subdomain aliases.portspecify port to to forward.directoryserve static content from the following directory.
directory directive and port directive can't be used together.
Port usage:
29430DNS responder29431HTTP reverse proxy
Distributed under MIT license.