I am using Vagrant on Windows 10.
I have installed centos 7 vagrant box,it is running correctly.
Vagrantfile is like this:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "dev"
config.vm.hostname = "vagrant-dev"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "private_network", ip: "192.168.33.3"
config.vm.synced_folder "d:/vagrant_env/www/", "/var/www"
end
I installed nginx in centos 7 vagrant box, and I can access nginx welcome page with ip 192.168.33.3.
I want to access it with domain name,so I configure C:\Windows\System32\drivers\etc\hosts
file in windows:
192.168.33.3 www.example.vagrant //add this line into hosts file of windows
and configure /etc/nginx/conf.d/default.conf file in centos 7:
server {
listen 80;
server_name www.example.vagrant;
//...
}
I try accessing www.example.vagrant on windows host,but it does not work.
what should I do?
There's two better solutions to this:
Use xip.io for your address. In this case http://example.192.168.31.3.xip.io/ will route to your address.
Set up a DNS entry for that which can be resolved. An inexpensive .com or .info test domain at a registrar which makes updating easy (e.g. Amazon Route 53) is always handy for this.
Some programs stubbornly refuse to read entries in /etc/hosts or the equivalent in Windows.
Navigate to 192.168.31.3:8080 in your browser. If you can see your server, then just make your redirect like that: 192.168.31.3:8080 www.example.vagrant
config.vm.network "forwarded_port", guest: 80, host: 8080
At this point you are saying "whatever happens inside Vagrant on port 80, forward it to port 8080 on host machine". You have to communicate with your Vagrant machine on port 8080.
Also your IP is wrong 192.168.33.3 vs 192.168.31.3
Related
I have drupalvm setup which has drupal installed. In my custom theme, I have styleguide running on port 6006 (can be configured to different as well as it's node app). I want to expose this to host system. when I do vagrant ssh -- -L 6006:localhost:6006 it's works fine and available on host. Now I have added below to Vagrantfile to make this permanent (as per document here - http://docs.drupalvm.com/en/latest/extending/vagrantfile/):
Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: 6006, host: 6006
end
Now I can see this port forwarded when I do vagrant port But I can't access localhost:6006 (or use already working drupal hostname - local.drupal.com:6006) on host machine. Do I have to add vhost for it in vagrant, if yes how? OR is there any other way to expose node app to host?
I'm trying to set up CouchDB (and ultimately use PouchDB) on a Scotch Box VM. The VM runs fine, and includes port forwarding for port 5849 by including the code below:
Vagrant.configure("2") do |config|
config.vm.box = "scotch/box-pro"
config.vm.hostname = "scotchbox"
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 5984, host: 5984
config.vm.network "forwarded_port", guest: 3000, host: 3000
config.vm.network "private_network", ip: "192.168.33.10"
The VM runs fine. localhost:8080 will load the PHP home page, and localhost:3000 will load a node script if I have the node server running, but localhost:5984 only returns an empty response when loaded from the browser or from the host machine command line using curl curl: (52) Empty reply from server.
When I have used vagrant ssh to access the VM, I can use curl localhost:5984 to obtain {"couchdb":"Welcome","uuid":"9cabeb8f66947adabe9443594aa7f69c","version":"1.6.0","vendor":{"version":"15.10","name":"Ubuntu"}} as expected.
Here is the guide I've been referring to: https://pouchdb.com/guides/setup-couchdb.html
Additional info: When I go to 192.168.33.10:5984 (instead of using the localhost port forwarding), the result is a refused connection.
Any suggestions as to what my issue might be? I had thought it was a forwarding issue, but the ports 8080 and 3000 work fine, and going to the IP:5984 doesn't work so it makes me wonder. I also thought maybe the service isn't running, but doing ssh on the VM and running curl seems to indicate that it is in fact running.
Thanks!
By default CouchDB bound to a localhost address 127.0.0.1 and you need to re-bind it to 0.0.0.0 to get it accessible from outside of Vagrant box. To do that you need to change parameter bind_address in [httpd] section of default.ini config file or add the same as override in local.ini config file.
On windows 10 I have ran my vagrant up and then ssh into my vm successfully. Installed apache2 php5-cli php5 libapache2-mod-php
Now when i access localhost:8080 it is showing me apache default welcome page. How can i access my site in the browser ?
Here are the contents of my Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "ubuntu/trusty64"
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network "forwarded_port", guest: 80, host: 8080
end
This is my current directory structure
You'll need to get your data into the VM and configure Apache to serve that data. For starters, add this to you Vagrantfile (after the confiv.vm.network line):
config.vm.synced_folder ".", "/var/www/html"
It will make your app folder available under /var/www/html on the VM. Apache on Ubuntu serves from that folder by default, so you should be able to see something after doing vagrant reload.
when you edit the configuration file by using vim or any other editor. After that, you have to reload the vagrant and then try to access the localhost:8080
Use the command
vagrant reload
I've been trying to change the mapping for a domain and forward it to a Vagrant machine that I've forwarded a port to.
The config in Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.network :forwarded_port, host: 4567, guest: 80
end
I've updated /etc/hosts on my Mac OSX with the following:
127.0.0.1:4567 example.com
Yet when I access from my browser example.com nothing changes, I have also tried to map example.com to go to the Google IP without any luck.
What am I overlooking?
I would just add a static ip, or try removing the port number:
Vagrant.configure("2") do |config|
config.vm.network "private_network", ip: "192.168.50.4"
end
Then in your hosts file change it to read:
192.168.50.4 example.com
More info is available here:
https://docs.vagrantup.com/v2/networking/private_network.html
So I'm working with vagrant and I'm trying to use it as a printing server. I installed cups.
Internally everything works just fine. I can even make a quick curl to my localhost:631 (cups port inside my vagrant) and there's everything.
The thing is I cant access it in any way I try from the host machine.
Obviously I forwarded the port and I've tried with several ports. I've also tried with Debian squeeze and Ubuntu 12.04. Here is my current Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "guruDebian"
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 631, host: 6363 ## HERE IS CUPS
end
Any ideas?
I think what you will find is that the default cups config file is locked down to only work from localhost for security reasons.
Inside your Vagrant VM open the /etc/cups/cupsd.conf file and change the following line:
Listen localhost:631
to
Listen 0.0.0.0:631
That should allow you to connect from any host.
Have you tried accessing port 8080 of guest to your host? if no, and the services inside guest are running. then its a firewall issue in guest.
Try to turn firewall temporarily
service iptables off
then try to access it again from host.