Title: how to access multiple sites from an external computer using scotch box 2
Tags: vagrant;vagrantfile
Question: I am running vagrant scotch box 2.0, I have added multiple domains to the box.

I have added the ip to my hosts file 

```845.888.9417 site1.local
845.888.9417 site2.local
```

The domains are working from local machine.

What I am wanting to do is allow access to these sites from another computer on the network 

I had added a port forward to vagrant file, and this works in a single domain environment.

but is there a way to somehow tie the domains in such a way that from an external computer they can access both domains, by simply adding a different port number , or some other way to get both sites to work externally?

I am not sure if this is relevant or not, but right now I am running scotch box on a mac, but I need the solution to also work on a windows system.

here is my vagrant file 

```# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

config.vm.box = "scotch/box"
config.vm.network "private_network", ip: "845.888.9417"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.hostname = "scotchbox"
config.vm.synced_folder "/Users/acc/Documents/vagrant/site1", "/var/www/site1.local/public",id:"1", :mount_options =&gt; ["dmode=777", "fmode=666"]
config.vm.synced_folder "/Users/acc/Documents/vagrant/site2", "/var/www/site2.local/public",id:"2", :mount_options =&gt; ["dmode=777", "fmode=666"]
config.vm.provision "shell", inline: <<-SHELL

    ## Only thing you probably really care about is right here
    DOMAINS=("site1.local" "site2.local")

    ## Loop through all sites
    for ((i=0; i < ${#DOMAINS[@]}; i++)); do

        ## Current Domain
        DOMAIN=${DOMAINS[$i]}

        echo "Creating directory for $DOMAIN..."
        mkdir -p /var/www/$DOMAIN/public

        echo "Creating vhost config for $DOMAIN..."
        sudo cp /etc/apache2/sites-available/scotchbox.local.conf /etc/apache2/sites-available/$DOMAIN.conf

        echo "Updating vhost config for $DOMAIN..."
        sudo sed -i s,scotchbox.local,$DOMAIN,g /etc/apache2/sites-available/$DOMAIN.conf
        sudo sed -i s,/var/www/public,/var/www/$DOMAIN/public,g /etc/apache2/sites-available/$DOMAIN.conf

        echo "Enabling $DOMAIN. Will probably tell you to restart Apache..."
        sudo a2ensite $DOMAIN.conf

        echo "So let's restart apache..."
        sudo service apache2 restart

    done

SHELL

# Optional NFS. Make sure to remove other synced_folder line too
#config.vm.synced_folder ".", "/var/www", :nfs =&gt; { :mount_options =&gt; ["dmode=777","fmode=666"] }

end
```



Here is another answer: The answer is that the additional domains need to go on different ports, then works

```# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

config.vm.box = "scotch/box"
config.vm.network "private_network", ip: "845.888.9417"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 81, host: 8081
config.vm.network "forwarded_port", guest: 82, host: 8082
config.vm.hostname = "scotchbox"
config.vm.synced_folder "/Users/acc/Documents/vagrant/main", "/var/www/public",id:"3", :mount_options =&gt; ["dmode=777", "fmode=666"]
config.vm.synced_folder "/Users/acc/Documents/vagrant/site1", "/var/www/site1.local/public",id:"1", :mount_options =&gt; ["dmode=777", "fmode=666"]
config.vm.synced_folder "/Users/acc/Documents/vagrant/site2", "/var/www/site2.local/public",id:"2", :mount_options =&gt; ["dmode=777", "fmode=666"]
config.vm.provision "shell", inline: <<-SHELL

    ## Only thing you probably really care about is right here
    DOMAINS=("site1.local" "site2.local")

    IPS=("81" "82")

    ## Loop through all sites
    for ((i=0; i < ${#DOMAINS[@]}; i++)); do

        ## Current Domain
        DOMAIN=${DOMAINS[$i]}

        MYIP=${IPS[$i]}

        echo "Creating directory for $DOMAIN..."
        mkdir -p /var/www/$DOMAIN/public

        echo "Creating vhost config for $DOMAIN..."
        sudo cp /etc/apache2/sites-available/scotchbox.local.conf /etc/apache2/sites-available/$DOMAIN.conf

        echo "Updating vhost config for $DOMAIN..."
        sudo sed -i s,scotchbox.local,$DOMAIN,g /etc/apache2/sites-available/$DOMAIN.conf
        sudo sed -i s,/var/www/public,/var/www/$DOMAIN/public,g /etc/apache2/sites-available/$DOMAIN.conf

   sudo sed -i s,80,$MYIP,g /etc/apache2/sites-available/$DOMAIN.conf

   sudo sed -i s,'<VirtualHost',"Listen $MYIP \\n<VirtualHost",g /etc/apache2/sites-available/$DOMAIN.conf



        echo "Enabling $DOMAIN. Will probably tell you to restart Apache..."
        sudo a2ensite $DOMAIN.conf

        echo "So let's restart apache..."
        sudo service apache2 restart

    done

SHELL

# Optional NFS. Make sure to remove other synced_folder line too
#config.vm.synced_folder ".", "/var/www", :nfs =&gt; { :mount_options =&gt; ["dmode=777","fmode=666"] }

end
```


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:09/15/16', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<vagrant><vagrantfile>', 'Title': 'how to access multiple sites from an external computer using scotch box 2', 'ViewCount': 320, 'id': 39520912, 'user_AboutMe': '', 'user_AccountId': 286605.0, 'user_DisplayName': 'Lawrence Cooke', 'user_Reputation': 1535.0, 'user_Views': 184.0, 'user_id': 585958.0}}