Last Updated: February 25, 2016
·
422
· gdotdesign

Easy Virtual Hosts on Ubuntu

For a while now I was struggling with setting up virtual hosts for development servers. I didn't want to install Apache just for this, so I used haproxy for a while but it is a pain to get it right (editing the configs and the hosts file is tiresome)

But now I found out how to do it in a jiff:

Install dnsmasq ( for resolving the domain ), and rinetd ( for port forwarding ).

sudo apt-get install dnsmasq rinetd

Edit /etc/dnsmasq.conf:

address=/dev/127.0.0.1

Edit /etc/rinetd.conf:

# bindadress    bindport  connectaddress  connectport
127.0.0.1       80        127.0.0.1       3000

logfile /var/log/rinetd.log

Restart services:

sudo service rinetd restart
sudo service dnsmasq restart

Now your virtual host is configured and ready to serve your sever that runs on port 3000 on anything.dev