Using to point domain to any host

Posted:   |  More posts about dns nginx

When I first heard about it from Armin Ronacher's twitter status last year, I don't really get what problem it solve and how it can be useful.
Working with a number of virtual instances from vagrant launched virtual machines or lxc container to instance of aws ec2 or digital ocean's droplet, all with varying IP address, I started to value something like xip. My /etc/hosts now has 90+ entries, some of it not used anymore. Everytime I have new instance to test with my app, I have to add new entry in /etc/hosts to point to that IP, and then forgot about it. simply resolve any subdomain of it to the ip address included as part of the subdomain. For example let say you have an app running at server with IP address The app has been configured to serve a domain called (using virtual host of the webserver). So that you can access the app using, you have to add in /etc/hosts the ip address of the server. Since is for development and it can be on any machine, adding it to your real dns server does not make sense so /etc/hosts a good fit for it. But that mean your /etc/hosts will quickly grow with list of entries that you might only use once.

So instead adding the IP to /etc/hosts, let resolve it. We can define the domain for as subdomain.[ip-address] and it will resolve to that [ip-address]. For example:-      -------->   --------> -------->    -------->

To actually serve the above sites, we have to change our web server config a bit so it can consider the above willcard. For example, for nginx, the config should look like:-

server {
        root /usr/share/nginx/dev;
        index index.html index.htm;

        server_name ~^dev\.myapp\.com\.(.*)\.xip\.io$;

This kind of service, coupled with others such as localtunnel or pagekite would be really helpful and as Armin said in the tweet, should in every developers toolbox.

Comments powered by Disqus

About me

Web developer in Malaysia. Currently work at MARIMORE Inc building internet services using Python and Django web framework.

ImportError is an error message emitted by Python when it failed to load certain module as requested by programmer. It's a very common error when someone new to the language trying it out. This website on the same theme, will try provide help for newcomers on any technologies to overcome their first hurdle.

Try most of the examples you may find here on Digital Ocean cloud service. They provide excellent VPS at a very cheaper price. Using this referral link you'll get USD10 credits upon sign up. That's enough to run single VPS with 1GB RAM for a month.


I can also be found at the following sites:-



The postings on this site are my own and don't necessarily represent my employer's positions, strategies or opinions.