I have a Win2012R2 virtual machine running in VirtualBox 5 using a Vagrant provisioning.
In the VM I run a single Consul 0.8.0 agent (I'm not interested in clustering at the moment) with the following command line:
consul.exe agent -server -dev -client=0.0.0.0 -bind=0.0.0.0
This launches Consul with the following attributes:
Server: true (bootstrap: false)
Client Addr: 0.0.0.0 (HTTP: 8500, HTTPS: -1, DNS: 8600)
Cluster Addr: 10.0.2.15 (LAN: 8301, WAN: 8302)
Gossip encrypt: false, RPC-TLS: false, TLS-Incoming: false
Atlas: <disabled>
So now I need to access this Consul agent, especially the REST api for putting and getting KV data, from the Host machine (Linux).
In order to do this, in the vagrantfile I configure the following port-forwarding:
config.vm.network "forwarded_port", guest: 8500, host: 8900
config.vm.network "forwarded_port", guest: 80, host: 5000
The port 80 is for exposing a WebApplication API that we deploy together in the VM, and which by the way is supposed to use Consul as configuration engine.
Accessing the application from the linux Host at address http://localhost:5000 works fine. However, if i try to read any Consul key at address http://localhost:8900/v1/kv/mykey, e.g. with curl, the session will be hanged indefinitely.
I guess it's worth remarking that both the webapplication API and the Consul APIs can be accessed from within the VM guest without problems.
I suspect the problem with Consul may lie with the need to expose / forward more ports from the Guest to the Host, like for example the port 8600? However I tried some experiments without success and at the moment I am blocked by this.
Or maybe the reason is the consul.exe command line launch, where I have to add more attributes?
What am I missing? Any idea how to make Consul agent accessible from the external world?
thanks!
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 want a vagrant VM to behave like a box not hosted on my host machine.
I want to be able to do
curl <vagrant private ip> #nginx on the vm
and have that work from the host machine
curl localhost #e.g. iis
and have that work from the host machine
but it seems it's not possible as when you do port forwarding it always occupies the host port too on the loopback/or IP and you cant restrict it to just the private IP of the VM, basically, you cant have the VM running and start iis.
If that is the case ok, that's that.
currently, my Vagrant file has
config.vm.network "forwarded_port", guest: 80, host: 80
config.vm.network "private_network", ip: "192.168.33.11
I know the forwarded_port has guest_ip and host_ip settings but I didn't find they did anything when I tried to set to the private network IP.
Any suggestion of easy workaround also welcome.
I've got this in my Vagrantfile:
web.vm.network "private_network", ip: "192.168.33.20"
web.vm.network "forwarded_port", guest: 80, host: 8080
but on my Mac Host I'm able to access the web VM using 192.168.33.20:80 but NOT 192.168.33.20:8080.
Why is this not working as expected?
vagrant Port forwarding is used if you dont have static IP and you want to reach a specific port for a process bound to this specific port running on the VM, so you will access it using http://localhost:8080 and it will forward to port 80 on the VM.
When you have a static IP, you reach directly the network interface to this VM so it tries to connect you on the port 8080 directly in the VM, if you dont have anything running there, it wont show up.
Rules: if you use static IP (wether private or public network) you dont need port forwarding
I have setup a centos virtual server using Vagrant and Puphpet, within the VM I have a java app running on jetty.
"server is running at http://127.0.0.1:9999"
However im having trouble accessing this from my local machine, I have set up a port forward so 9999 forwards to 9999, but when i visit awesome.dev:9999 or 192.168.56.103:9999 I get a site cant be reached error.
Obviously im missing something in my puphpet config.yaml file, I'm just not sure what.
machines:
vflm_b214h6dav8jj:
id: machine1
hostname: machine1.puphpet
network:
private_network: 192.168.56.103
forwarded_port:
vflmnfp_hmt0pd4imhhd:
host: '5997'
guest: '22'
vflmnfp_b74egg9hlvog:
host: '9999'
guest: '9999'
memory: '1024'
cpus: '1'
If I goto awesome.dev then the hello world page I put in is working, so I know the VM is up and running.
The issue is
"server is running at http://127.0.0.1:9999"
so its not accessible on any network interface other than your localhost.
You need to change this to get started the app on the IP of the server or you can use 0.0.0.0 (special IP so all interfaces can access it)
You need to change the jetty.host property, there's a few possibilities
start the server using the following command:
java -Djetty.host=0.0.0.0 -jar start.jar
define the host in your connector
<New class="org.eclipse.jetty.server.ServerConnector">
<Set name="host">0.0.0.0</Arg>
....
</New>
make a new system properties when working with ant jetty-build.xml
<systemProperty name="jetty.ant.server.host" value="0.0.0.0"/>
I have recently started using Vagrant instead of MAMP for some small projects (mainly WordPress) However, decided to try my hand at React and am wondering wether it is possible to use the two together?
At the moment I have a Vagrant setup created via PuPHPet which works fine and runs a local server on a VM which I can access via a URL - local.gethandle.com. I also downloaded a React starter kit as a starting point from a Facebook github page and it requires you to run a server e.g. node server.js which also works and I can access from a separate URL - http://localhost:3000/. But cant seem to access my React application via my Vagrant URL.
How do I combine the two? If at all possible.
Oki doki,
caveat: I've not looked at what kind of VM is provisioned via PuPHPet..
First you'll need to vagrant ssh into your vagrant vm and download the react tools into your vagrant vm
https://docs.vagrantup.com/v2/getting-started/up.html
Second you'll then want to edit your Vagrant file that should be in the directory on your machine where your vagrant settings are, then have a look and add some networking config
https://docs.vagrantup.com/v2/getting-started/networking.html
config.vm.network :forwarded_port, guest: 80, host: 4567
# guest is your machine, host is your vagrant vm
# e.g config.vm.network :forwarded_port, guest: 3000, host: 3000
You probably need to add the port to your firewall: