Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant "domain forwarding"

Currently, I've got used to creating development domains like: projecttowork.dev.

Now I have a project, where I have to use subdomains as well, so like: module1.project.dev

I would like to start using Vagrant, because it looks awesome and I work together with some other people, and it would be great to have the same server everywhere.

In Vagrant, of course I can forward a port, like :8000 and get the server on virtual machine, but I can not figure out, how to "forward" a domain.

I tried different ways, but without any success.

Some details:

  • OS: Windows 8
  • Vagrant box: basic Ubuntu 12.04 LTS
  • Webserver on client: Nginx
  • Webserver on host: Apache (if needed)

How could I redirect this development domain to the virtual server?

like image 462
seniorpreacher Avatar asked Jan 08 '14 14:01

seniorpreacher


Video Answer


1 Answers

-My settings in Vagrant file for network is:

config.vm.network "private_network", ip: "192.168.20.20" #choose you own

-In the host machine in /etc/hosts (linux) Windows/system32/driv.../hosts (windows)

192.168.20.20 domain.tld 

-On the box check firewall (iptables - if the box is linux).

  • either deactivate your firewall on the box(I did this) or setup it to allow access from the host machine. (http://www.cyberciti.biz/tips/linux-iptables-examples.html)

-In the box set virtualhost for this domain (just an example):

<VirtualHost *:80>
  ServerName domain.tld

  DocumentRoot "/path"
  RewriteEngine On

  <Directory "/path">
    Options Indexes FollowSymLinks
  </Directory>
</VirtualHost>
like image 187
Tomor Avatar answered Oct 04 '22 21:10

Tomor