mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
add gateway_ports option
This allows access to forwarded ports from outside the host. Fixes #231.
This commit is contained in:
@@ -309,6 +309,12 @@ vagrant-libvirt supports Forwarded Ports via ssh port forwarding. For each
|
|||||||
`forwarded_port` directive you specify in your Vagrantfile, vagrant-libvirt
|
`forwarded_port` directive you specify in your Vagrantfile, vagrant-libvirt
|
||||||
will maintain an active ssh process for the lifetime of the VM.
|
will maintain an active ssh process for the lifetime of the VM.
|
||||||
|
|
||||||
|
vagrant-libvirt supports an additional `forwarded_port` option
|
||||||
|
`gateway_ports` which defaults to `false`, but can be set to `true` if
|
||||||
|
you want the forwarded port to be accessible from outside the Vagrant
|
||||||
|
host. In this case you should also set the `host_ip` option to `'*'`
|
||||||
|
since it defaults to `'localhost'`.
|
||||||
|
|
||||||
## Synced Folders
|
## Synced Folders
|
||||||
|
|
||||||
vagrant-libvirt supports bidirectional synced folders via nfs or 9p and
|
vagrant-libvirt supports bidirectional synced folders via nfs or 9p and
|
||||||
|
|||||||
@@ -53,7 +53,8 @@ module VagrantPlugins
|
|||||||
fp[:host_ip] || 'localhost',
|
fp[:host_ip] || 'localhost',
|
||||||
fp[:host],
|
fp[:host],
|
||||||
fp[:guest_ip] || @env[:machine].provider.ssh_info[:host],
|
fp[:guest_ip] || @env[:machine].provider.ssh_info[:host],
|
||||||
fp[:guest]
|
fp[:guest],
|
||||||
|
fp[:gateway_ports] || false
|
||||||
)
|
)
|
||||||
store_ssh_pid(fp[:host], ssh_pid)
|
store_ssh_pid(fp[:host], ssh_pid)
|
||||||
end
|
end
|
||||||
@@ -78,13 +79,15 @@ module VagrantPlugins
|
|||||||
mappings.values
|
mappings.values
|
||||||
end
|
end
|
||||||
|
|
||||||
def redirect_port(machine, host_ip, host_port, guest_ip, guest_port)
|
def redirect_port(machine, host_ip, host_port, guest_ip, guest_port,
|
||||||
|
gateway_ports)
|
||||||
ssh_info = machine.ssh_info
|
ssh_info = machine.ssh_info
|
||||||
params = %W(
|
params = %W(
|
||||||
"-L #{host_ip}:#{host_port}:#{guest_ip}:#{guest_port}"
|
"-L #{host_ip}:#{host_port}:#{guest_ip}:#{guest_port}"
|
||||||
-N
|
-N
|
||||||
#{ssh_info[:host]}
|
#{ssh_info[:host]}
|
||||||
).join(' ')
|
).join(' ')
|
||||||
|
params += ' -g' if gateway_ports
|
||||||
|
|
||||||
options = (%W(
|
options = (%W(
|
||||||
User=#{ssh_info[:username]}
|
User=#{ssh_info[:username]}
|
||||||
|
|||||||
Reference in New Issue
Block a user