Thursday 12 May 2016

Accessing virtual host from Android

In this post I am going to describe, how to make api calls or connect to virtual host from Android. 

First lets clear some terminology.

Hosts file is generally a system file which resides in a folder called etc on linux and mac. This file is used for domain name to ip address mapping when you browse some url on your browser. If that url is not found there then browser checks to the local DNS or cached DNS and then ISP's DNS and so on.

Rooted Phone, in general term its like you are removing almost all the securities of Android. You can modify the system file and almost can change everything you want. That's why it is not recommended to do this. Hence I am providing another way to solve this issue.

The basic problem is, if your phone is not rooted then you will not be able to modify its hosts file easily. So you can not add a entry in /etc/hosts file like domain nerds.are@awesome.com should point to the ip address aaa.bb.cc.dd. You also can not use the nerds.are@awesome.com for connection from phone because it is private domain of a virtual host server not public domain hence not accessible publicly.

In Desktop generally you can simply modify the /etc/hosts file like add a entry:

127.0.0.1     localhost
aaa.bb.cc.dd  nerds.are@awesome.com

So somehow you have to use your Desktop's hosts file in between your connection to the virtual host. So you can use any proxy server, I used Charle's Proxy tool for mac. You can use some other tools also. This proxy server will make your request look like it is being generated from your laptop or desktop and will be able to use the hosts file for mapping.

Charles Proxy Tool

For How to Configure Charle's Proxy : Please visit my next post.

I hope it helps. Till next time Keep Calm and Profile Your Code. Perf. Matters.

No comments:

Post a Comment

Related Posts

Related Posts Plugin for WordPress, Blogger...