I setup a nginx+mysql puphpet/vagrant image, with a virtual host "test.com". I mapped test.com to 192.168.56.101 on the host machine, and put an index.php file inside /var/www/test.
However, when I try opening the browser at the address test.com on the host machine I get no response. I feel like I'm missing something really simple, because I can ping 192.168.56.101. I also checked nginx logs on the virtual machine, but they are empty. Any clues where the problem might be? Am I not supposed to use it this way? I can ssh into vagrant just fine, and also I can access the mysql db.
In your Vagrantfile, you need to forward the port to your host machine.
For example map port 80 of the Vagrant machine to port 8080 of the host machine.
config.vm.network "forwarded_port", guest: 80, host: 8080
Related
I am having debian vagrant. I have done virtual host configuration in its apache as servername https:local-dev02.sitename.com. And used in my windows machine host file 127.0.0.1 local-dev02.sitename.com.
I can access my site in windows' browser as https://local-dev02.sitename.com:8443/.
But I am unable to do
ping https://local-dev02.sitename.com
OR
curl https://local-dev02.sitename.com
OR
wget https://local-dev02.sitename.com
It is only possible to ping a hostname or IP address, but not an URL. So you need to put off the protocol like so
ping local-dev02.sitename.com
To reach your hosts via the hostnames, please add the IPs and hostnames to the /etc/hosts file.
I have a WebSocket server using Ratchet (literally the example app). I'm serving it to localhost:8080 on my Vagrant machine (which is a CentOS 6) and trying to connect to it through the private network IP set in the Vagrantfile 192.168.33.10.
I'm getting a connect ECONNREFUSED 192.168.33.10:8080 (the uri is ws://192.168.33.10:8080/chat).
I already exposed the port config.vm.network "forwarded_port", guest: 8080, host: 8080.
I've tried serving the server (inside vagrant) to localhost, 127.0.0.1 and 192.168.33.10, but the client still can't connect.
It works fine outside of Vagrant using localhost on both client and server.
What am I missing?
If you bind the app to localhost there is no way you can access it via 192.168.33.10, hence port forwarding won't work either.
You need to make your app to listen on 192.168.33.10:8080.
Also add the guest's IP address to the Vagrantfile:
config.vm.network "forwarded_port", guest_ip: "192.168.33.10", guest: 8080, host: 8080
I want to display Symfony2 page using vagrant box.
If i turn on vagrant box (vagrant up), and use by ssh command "php app/console server:run"
Then i see info " Server running on http://127.0.0.1:8000 "
and if i go to the website "192.168.33.10" or "127.0.0.1" or "127.0.0.1:8000" on host machine, Then i don't see symfony2 site.
Question: How is correctly configuration the vagrant file, that allow me see symfony2 site ?
Its keys lines in my vagrant file .
....
config.vm.box = "symfony-v0.2.0"
config.vm.network "forwarded_port", guest: 8000, host: 80
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.network "public_network"
config.vm.synced_folder "./", "/var/www/"
....
Add informations:
==> default: Mounting shared folders...
default: /var/www => C:/Users/Wojtek/PhpstormProjects/DragonisProject/Symfony2Project
default: /vagrant => C:/Users/Wojtek/PhpstormProjects/DragonisProject/Symfony2Project
Delete line config.vm.network "private_network", ip: "192.168.33.10" from Vagrantfile.
Then start server server as php app/console server:run 0.0.0.0:8000 it will listen to all ip addresses and access it as http://localhost because you have port 8000 forwarded to port 80 on host machine.
1) Make sure you set your local host file to point your site to the correct vagrant IP (192.168.33.10), if applicable. Otherwise just use the IP directly.
2) If your vagrant instance is running, the issue is likely due to your apache conf within the vagrant box.
Make sure you have the proper Apahce/nginx vhost in place for your site.
Why ?
I've set up an extremely simple server, like 50 times before, but this is my first try with Vagrant.
Current behaviour:
Vagrant VM shows "SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1" in browser when navigating to "127.0.0.1:2222". 2222 is the standard port for the first Vagrant VM.
Expected behaviour:
127.0.0.1 should show the index.html/php of the apache2 web folder.
When you run a vagrant up, you'll see a message showing [default] Forwarding ports... -- 22 => 2222 (adapter 1). ssh is listening on port 22 on your VM, you can ssh to port 22 (default) from your local box to connect to the VM; but if you have configured the VM to allow external access, then anyone else on another machine needs to use your IP address but port 2222 to connect to the VM.
This might be useful if you ran the VM on a box in work, but wanted to be able to access it when you were at home, or in a client's office, or even from another machine in your work's network.
Using a browser to connect to the SSH port 2222 will redirect to port 22 on the virtual box, but it's ssh that's listening on this port; and a web-browser isn't the right tool for an ssh connection.
Personally I use putty as my ssh client, but with vagrant you can also issue a vagrant ssh after starting the virtual machine.
Additional
The values of port forwarding
If you set
config.vm.network :forwarded_port, guest: 80, host: 8080
config.vm.network :forwarded_port, guest: 443, host: 8443
in your vagrantFile, and you've allowed public access to the VM, then you can access the webserver on the VM from home, a client or another box in your work network by pointing the browser to port 8080 (or 8443 for https) rather than the more normal default ports 80 and 443... which can be particularly useful for running demos from a laptop that you can take to a client site while your VM is running on a bulky desktop under your desk in work
MarkBaker's answer solves the problem, but Vagrant 1.2.7 (and newer) needs this syntax:
# Forward guest port 80 to host port 80
config.vm.forward_port 80, 80
The full Vagrantfile (you can find it where your box file is) would look like this:
Vagrant::Config.run do |config|
# Forward guest port 80 to host port 80
config.vm.forward_port 80, 80
end
This example would route a request on port 80 (standart port) in your host OS to port 80 in your Vagrant VM. The result is, http://127.0.0.1 in the host browser will show you the localhost of the VM.
When working with multiple VMs please notice that you should use a unique port for every VM.
This is odd...
I installed Zend Server to test it out. Turns out I don't like it and I wanted to go back to MAMP. But after the Zend Server CE uninstall, "localhost" no longer works. I can only access MAMP from 127.0.0.1
Frustrating and I'm not liking it at all.
Any ideas?
hosts:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 mydomain.loc www.mydomain.loc
nslookup says:
Server: 64.59.160.13
Address: 64.59.160.13#53
Non-authoritative answer:
Name: localhost
Address: 127.0.0.1
I was told by a college that sometimes the only thing you can do to wake up port 80 on the Mac is to enable the built in web server and then disable it again.
So I did that and all is well.
you mention 127.0.0.1 which is a IPv6 address. Many (all?) modern operating systems are configured to resolve localhost using IPv6 to ::1. My assumption would be that your MAMP setup is not listening via IPv6. Try opening http://[::1]/ if that works there is an error in our resolve configuration, if not (what I expect) you have to configure your web server to either lsiten to ::1 or any device.
This can be done in httpd.conf using
Listen 80
to listen on all devices, port 80 or
Listen [::1]:80
to listen to localhost via IPv6 only. Mind not having conflicting VHost entries etc.