I have a working vagrant VM I want to Share. In my Vagrantfile I have:
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "private_network", ip: "192.168.1.15"
config.vm.network "forwarded_port", guest: 443, host: 443
in the virtual host I have
<VirtualHost *:443>
...
ServerAlias *.vagrantshare.com
....
</Virtualhost>
not sure about the first line but it was there already
I share the machine with
vagrant share --https 443
this is the output:
==> default: Detecting network information for machine...
default: Local machine address: 127.0.0.1
default:
default: Note: With the local address (127.0.0.1), Vagrant Share can only
default: share any ports you have forwarded. Assign an IP or address to your
default: machine to expose all TCP ports. Consult the documentation
default: for your provider ('virtualbox') for more information.
default:
default: Local HTTP port: 8080
default: Local HTTPS port: 443
default: Port: 2222
default: Port: 443
default: Port: 8080
==> default: Checking authentication and authorization...
==> default: Creating Vagrant Share session...
default: Share will be at: towering-badger-9312
==> default: Your Vagrant Share is running! Name: towering-badger-9312
==> default: URL: http://towering-badger-9312.vagrantshare.com
==> default:
==> default: You're sharing your Vagrant machine in "restricted" mode. This
==> default: means that only the ports listed above will be accessible by
==> default: other users (either via the web URL or using `vagrant connect`).
I can see it in vagrant cloud but I got an error while trying to access it via https:
towering-badger-9312.vagrantshare.com is currently unable to handle this request.
HTTP ERROR 500
not any other useful message in the console, any idea how to debug this?
thanks
Replace this line
config.vm.network "forwarded_port", guest: 443, host: 443
with i.e.
config.vm.network "forwarded_port", guest: 443, host: 8443
first, because forwarded_port is for accessing from your host and second, you should not be able to bind to port 443 on host.
Also
vagrant share --https 443
is redundant (docs):
HTTPS (SSL)
Vagrant Share can also expose an SSL port that can be accessed over
SSL. For example, instead of accessing http://foo.vagrantshare.com, it
could be accessed at https://foo.vagrantshare.com.
vagrant share by default looks for any SSL traffic on port 443 in your
development environment. If it cannot find any, then SSL is disabled
by default.
so
vagrant share
should suffice (assuming there's no other issue).
Related
I'm following the instructions at this link: https://github.com/hyperledger/fabric/blob/master/examples/e2e_cli/end-to-end.rst
I have set the development environment following instructions here (http://hyperledger-fabric.readthedocs.io/en/latest/dev-setup/devenv.html)
Now when inside the devenv folder I run 'vagrant up', I get the following:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'hyperledger/fabric-baseimage'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'hyperledger/fabric-baseimage' is up to date...
==> default: Setting the name of the VM: hyperledger
==> default: Destroying VM and associated drives...
C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant- 1.9.3/lib/vagrant/util/is_port_open.rb:21:in `initialize': The requested address is not valid in its context. - connect(2) for "0.0.0.0" port 7050 (Errno::EADDRNOTAVAIL)
I appreciate some help here.
This is a problem with vagrant 1.9.3 which should be fixed in the next release:
https://github.com/mitchellh/vagrant/pull/8399
In the meantime you can work around it by specifying in the Vagrantfile the host ip in every port forwarding command:
config.vm.network :forwarded_port, guest: 7050, host: 7050, host_ip: "127.0.0.1" # fabric orderer service
config.vm.network :forwarded_port, guest: 7051, host: 7051, host_ip: "127.0.0.1" # fabric peer service
config.vm.network :forwarded_port, guest: 7053, host: 7053, host_ip: "127.0.0.1" # fabric peer event service
config.vm.network :forwarded_port, guest: 7054, host: 7054, host_ip: "127.0.0.1" # fabric-ca service
config.vm.network :forwarded_port, guest: 5984, host: 15984, host_ip: "127.0.0.1" # CouchDB service
With this change vagrant up works for me.
I'm trying to create a multi vm setup using vagrant where only the server's exposed port needs to be forwarded to the specified host machine port. Client ports need not be exposed. But when I try to do this using the attached Vagrantfile, it for some reason is evaluating my if condition for filtering the clients out, true for clients also. Can someone point out what I may be doing wrong here?
Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = '2'
BASEBOX = 'centos-6.7'
BOX_MEMORY = '256'
# Declare the cluster config in a hash
HOST_CONFIG = {
'some_server' => '192.168.205.10',
'some_client' => '192.168.205.11'
}
# Create the vms
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = BASEBOX
HOST_CONFIG.each do |hostname, hostip|
config.vm.network "forwarded_port", guest: 80, host: 8080 if hostname == "some_server"
config.vm.define hostname do |hname|
hname.vm.provider 'virtualbox' do |v|
v.name = hostname
v.customize [ 'modifyvm', :id, '--cpus', '1' ]
v.customize [ 'modifyvm', :id, '--memory', BOX_MEMORY ]
end
hname.vm.network 'private_network', ip: hostip
hname.vm.provision :hosts do |provisioner|
provisioner.autoconfigure = true
provisioner.sync_hosts = true
end
hname.vm.provision 'ansible' do |ansible|
ansible.playbook = 'bootstrap.yml'
end
end
end
end
Output:
$ vagrant up
Bringing machine 'server' up with 'virtualbox' provider...
Bringing machine 'client' up with 'virtualbox' provider...
==> server: Importing base box 'centos-6.7'...
==> server: Matching MAC address for NAT networking...
==> server: Setting the name of the VM: server
==> server: Clearing any previously set network interfaces...
==> server: Preparing network interfaces based on configuration...
server: Adapter 1: nat
server: Adapter 2: hostonly
==> server: Forwarding ports...
server: 80 (guest) => 8080 (host) (adapter 1)
server: 22 (guest) => 2222 (host) (adapter 1)
==> server: Running 'pre-boot' VM customizations...
==> server: Booting VM...
==> server: Waiting for machine to boot. This may take a few minutes...
server: SSH address: 127.0.0.1:2222
server: SSH username: vagrant
server: SSH auth method: private key
server: Warning: Remote connection disconnect. Retrying...
server: Warning: Remote connection disconnect. Retrying...
==> server: Machine booted and ready!
==> server: Checking for guest additions in VM...
==> server: Configuring and enabling network interfaces...
==> server: Mounting shared folders...
server: /vagrant => /Users/ANJUWAA/Projects/Nagios
==> server: Running provisioner: hosts...
==> client: Importing base box 'centos-6.7'...
==> client: Matching MAC address for NAT networking...
==> client: Setting the name of the VM: client
Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 8080 is already in use
on the host machine.
To fix this, modify your current project's Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:
config.vm.network :forwarded_port, guest: 80, host: 1234
Sometimes, Vagrant will attempt to auto-correct this for you. In this
case, Vagrant was unable to. This is usually because the guest machine
is in a state which doesn't allow modifying port forwarding.
Now you are effectively setting the vm.network value for all machines if one of them is named some_server.
You should place the vm.network setting inside the vm.define-loop:
HOST_CONFIG.each do |hostname, hostip|
config.vm.define hostname do |hname|
hname.vm.network "forwarded_port", guest: 80, host: 8080 if hostname == "some_server"
hname.vm.provider 'virtualbox' do |v|
v.name = hostname
v.customize [ 'modifyvm', :id, '--cpus', '1' ]
v.customize [ 'modifyvm', :id, '--memory', BOX_MEMORY ]
end
Trying to run two vagrant instances on the same host. The vagrant files on the first instance does nothing special with the SSH ports:
# 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: 8080, host: 9080
config.vm.network "forwarded_port", guest: 8081, host: 9081
config.vm.network "forwarded_port", guest: 9990, host: 9090
config.vm.network "forwarded_port", guest: 8983, host: 8983
config.vm.network "forwarded_port", guest: 8985, host: 8985
config.vm.network "forwarded_port", guest: 2181, host: 2181
config.vm.network "forwarded_port", guest: 8002, host: 8002
# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
# config.ssh.forward_agent = true
And this instance spins up as expected:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/precise32' is up to date...
==> default: Resuming suspended VM...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection refused. Retrying...
==> default: Machine booted and ready!
The second instance forwards port guest 22 to host 2221:
# 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: 8080, host: 10080
config.vm.network "forwarded_port", guest: 80, host: 45678
config.vm.network "forwarded_port", guest: 9999, host: 10999
config.vm.network "forwarded_port", guest: 9000, host: 10900
config.vm.network "forwarded_port", guest: 22, host: 2221
But when it spins up, I'm still getting conflicts on port 22222:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/precise32' is up to date...
Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 2222 is already in use on the host
machine.
To fix this, modify your current projects Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:
config.vm.network :forwarded_port, guest: 22, host: 1234
Sometimes, Vagrant will attempt to auto-correct this for you. In this
case, Vagrant was unable to. This is usually because the guest machine
is in a state which doesn't allow modifying port forwarding.
So I had this working, with the same two vagrant files 3 months ago. It seems like there has been an update to the underlying 'hashicorp/precise32' boxes without a corresponding documentation change, and modifications to the ssh port forrwarding are no longer allowed? Updating the config.ssh.port would seem to require a change to the underlying image.
Thoughts?
==================================================
Update:
Launching the 2nd instance (forwards 22 => 2221), then reloading produces the following output:
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'hashicorp/precise32' is up to date...
==> default: Resuming suspended VM...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection refused. Retrying...
==> default: Machine booted and ready!
Elizabeth#Work /cygdrive/c/Gui-again
$ vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'hashicorp/precise32' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 8080 => 10080 (adapter 1)
default: 80 => 45678 (adapter 1)
default: 9999 => 10999 (adapter 1)
default: 9000 => 10900 (adapter 1)
default: 22 => 2221 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
default: The guest additions on this VM do not match the installed version of
default: VirtualBox! In most cases this is fine, but in rare cases it can
default: prevent things such as shared folders from working properly. If you see
default: shared folder errors, please make sure the guest additions within the
default: virtual machine match the version of VirtualBox you have installed on
default: your host and reload your VM.
default:
default: Guest Additions Version: 4.2.0
default: VirtualBox Version: 4.3
==> default: Mounting shared folders...
default: /vagrant => C:/OSC/PBD-Gui-again
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run
So somewhere the ssh port is being forced to 2222. This isn't in the vagrant file itself, where else to look?
You can try adding an 'id ssh' to the end
config.vm.network :forwarded_port, guest: 22, host: 2221, id: 'ssh'
Or maybe this works for you, to first disable the ssh port (Depends on the Vagrant version)
config.vm.network :forwarded_port, guest: 22, host: 2221, id: "ssh", disabled: true
config.vm.network :forwarded_port, guest: 22, host: 2221, auto_correct: true
Source:
https://github.com/mitchellh/vagrant/issues/3232
My running vagrant box (ubuntu, on a OS X Mavericks host) has been running fine.
I am trying to set up pgAdmin from the host, and am having trouble opening a new port for the sql traffic.
I added a line to my Vagrantfile (the last one):
config.vm.network "forwarded_port", guest: 3000, host: 8080 # http
config.vm.network :forwarded_port, guest: 35729, host: 35729
config.vm.network "forwarded_port", guest: 5432, host: 7001 # postgres
I ran vagrant provision and bounced the Vagrant box several times. When it reboots the new port forwarding is not listed:
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 3000 => 8080 (adapter 1)
default: 35729 => 35729 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:2222
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
Curl gives a negative response also:
➜ ~ curl -v 'http://localhost:7001/'
* Adding handle: conn: 0x7fde1a004400
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fde1a004400) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 7001 (#0)
* Trying ::1...
* Trying 127.0.0.1...
* Trying fe80::1...
* Failed connect to localhost:7001; Connection refused
* Closing connection 0
curl: (7) Failed connect to localhost:7001; Connection refused
Related posts:
Vagrant Port Forwarding not working
Cannot connect to Postgres running on VM from host machine using MD5 method
Another way to set up a temporary terminal, besides opening up the VirtualBox settings, is to use vagrant ssh, with additional arguments given after the --:
vagrant ssh -- -L 3000:localhost:3000
This will forward port 3000 on the host to port 3000 on the guest.
The first number is for the host. To forward port 7001 on the host to the default postgresql port on the guest:
vagrant ssh -- -L 7001:localhost:5432
This will only last as long as your ssh session. If ssh gets disconnected, run it again. To make it persist after restarts, add it to your Vagrantfile.
Since the 5432<-->7001 port mapping is not listed in the Vagrant up sequence, it's not happening.
I would try a vagrant reload which is supposed to reload those part of the Vagrantfile again.
If that doesn't work, you could also try manually adding the port mapping, at least to confirm the connection to your application. The accepted answer for Change Vagrant port forwarding on a running system explains how to do that in the VirtualBox UI.
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