How to Rails share virtual host at localhost by Pow + xip.io
You can easily change the virtual host to [project-name].dev
just by adding a symbolic link.
If you use xip, you can also easily share it with people in the same network.
Install Pow
Official site: Pow: Zero-configuration Rack server for Mac OS X
$ curl get.pow.cx | sh
.
Install Anvil
Official site: Anvil for Mac - Run your sites locally
What is xip.io?
It is a domain that resolves names to the IP address itself if you put the IP address in a subdomain, created by a DNS server that can use PowerDNS as a backend for various things.
For example, you can access your localhost with a URL like the following (which resolves to 127.0.0.1) Easy Virtual Hosting with xip.io - ngyuki’s Diary
Check local IP address with ifconfig
1
2
3
4
5
6
$ ifconfig
<skip>
en0:
inet [ip-adress]
With the combination of pow + xip.io, I was able to share my local pow configuration [repository name.dev]
to other people with [repository name]. [local IP address].xip.io
. xip.io is useful.
$ curl curl -XPOST -v -H 'Content-Type: application/json' http://[project-name]. [local-ip-address].xip.io/api/v1/auth/sign_in -d '{"email": "test@example.com", "password": "testtest" }