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.
Related
I am working on a chef project which is running in Vagrant. I have installed chef server on my local machine and I need to connect it from vagrant instance. I am getting a connection refused. I have added port-forwarding, but vagrant wont let me forward port-443 as it's already occupied. My chef server is running on https i.e port-443.
Error log :
[2019-05-03T10:21:00+00:00] INFO: Client key /etc/chef/client.pem is not present - registering
[2019-05-03T10:21:00+00:00] ERROR: Connection refused connecting to https://my-system-product-name/organizations/internetdevelopment/clients, retry 1/5
[2019-05-03T10:21:05+00:00] ERROR: Connection refused connecting to https://my-system-product-name/organizations/internetdevelopment/clients, retry 2/5
VagrantFile :
Vagrant.configure("2") do |config|
config.vm.network "forwarded_port", guest: 443, host: 8443
config.vm.network "forwarded_port", guest: 80, host: 8080
i would offer you to assign a static ip address to your vagrant virtual machine (vm) rather than use a port forwarding.
You can also specify a static IP address for the machine. This lets you access the Vagrant managed machine using a static, known IP. The Vagrantfile for a static IP looks like this:
Vagrant.configure("2") do |config|
config.vm.network "private_network", ip: "192.168.50.4"
end
It is up to the users to make sure that the static IP does not collide with any other machines on the same network.
While you can choose any IP you would like, you should use an IP from the reserved private address space. These IPs are guaranteed to never be publicly routable, and most routers actually block traffic from going to them from the outside world.
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 couldn't manage to publish a virtual machine's port this way:
config.vm.define "n1" do |n1|
n1.vm.hostname = "n1"
n1.vm.network "private_network", ip: "172.20.20.10"
n1.vm.network "forwarded_port", guest: 8500, host: 8080
end
Access inside the VM works fine:
vagrant#n1:~$ curl http://localhost:8500/v1/health/state/any
but host access (outside of the VM, from my computer web browser) won't work:
http://localhost:8080/v1/health/state/any
Is what I try to achieve possible? Can somebody give me an hint, please?
I am not vagrant expert. BUT, in networking, you CANNOT forward port that bind to localhost(127.0.0.1) without explicitly mentioned it. Universal binding only works for 0.0.0.0.
You may try this, but I wouldn't guarantee it will works
n1.vm.network "forwarded_port", guest: 8500, guest_ip: 127.0.0.1, host: 8080
It is better to start your application binding to IP address then do the forwarding.
If I run apache and varnish on vagrant and run the following on the guest and host it works fine:
//guest
wget http://localhost/app_dev.php
//host
wget http://localhost:8080/app_dev.php
My Vagrantfile looks like this:
config.vm.network "forwarded_port", guest: 80, host: 8080
Now I'll try ssl so change it to
config.vm.network "forwarded_port", guest: 443, host: 8080
Then on the guest I start httpd, varnish and pound. Now I can't connect anymore from host:
//on guest:
wget --no-check-certificate https://localhost:443/app_dev.php
//results in 200 OK
//on host
wget --no-check-certificate https://localhost:8080/app_dev.php
//results in
//--2014-06-22 23:43:34-- https://localhost:8080/app_dev.php
//Resolving localhost (localhost)... 127.0.0.1
//Connecting to localhost (localhost)|127.0.0.1|:8080... connected.
//Unable to establish SSL connection.
Not sure what the problem is here, is it not allowed to create ssh over 8080?
When trying the following in Vagrantfile
config.vm.network "forwarded_port", guest: 443, host: 443
I get a warning while starting up:
==> default: You are trying to forward to privileged ports (ports <= 1024). Most
==> default: operating systems restrict this to only privileged process (typically
==> default: processes running as an administrative user). This is a warning in case
==> default: the port forwarding doesn't work. If any problems occur, please try a
==> default: port higher than 1024.
But still the same error when trying a wget from host.
Is it possible to make https connection from host to guest with vagrant? If so then how?
I'm using the fedora 20 box. Tried with the following settings in Vagrantfile:
config.vm.network "private_network", ip: "33.33.33.10"
Then added to my hosts
33.33.33.10 site
When I start httpd, varnish and pound on the guest (httpd listens to 8080, varnish to 80 and Pound to 443) I can get http:site/, http:site:8080 but no https:site (had to remove // or can't post it) where a wget from guest works (response 200 with expected html)
On the guest I've tried
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
But same result, I can't think of a reason why Vagrant fedora box would have https port blocked though but it could be as I've got no idea how to use iptables.
It was a problem in pound, the /etc/pound.cfg looked like:
ListenHTTPS
Address localhost
Port 443
changed to:
ListenHTTPS
Address 33.33.33.10
Port 443
Solved the problem
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.