-
Notifications
You must be signed in to change notification settings - Fork 150
How To: Port Forwarding on VirtualBox
Beginning in Panamax Installer version 0.2.1, Panamax automatically creates a private IP for you CoreOS VM -- 10.0.0.200
. You can use this to access your application when you have a host port assigned to your container. For example, if you have the following host to container port binding: 8080 : 80 / TCP
, you can access your service using the private IP address: http://10.0.0.200:8080
.
If you opted for Panamax to create an alias for the private IP during installation or reinstallation, you can access your application's services via that domain. For example: http://panamax.local:8080
.
If your application has an endpoint that you need to be able to access outside of the container, you need a port exposed on the CoreOS host that points to the port in the container hosting the endpoint. For example, if your application runs an HTTP server on port 80, you need to bind a port from CoreOS to port 80 within Panamax. The following shows the host port, 8080, bound to the container port, 80.
CoreOS can now access the web app via port 8080; however, in order to reach that endpoint from your local machine, we need to make another hop from our local machine to the CoreOS port. To do this, we need to make a port forwarding rule in VirtualBox to port 8080.
This can be accomplished in two ways: 1) via the terminal windows of your local machine, or 2) via the VirtualBox GUI.
###Port Forwarding via the terminal window
On your local machine, open a terminal window and run the following command:
$ VBoxManage controlvm panamax-vm natpf1 rule1,tcp,,8997,,8080
This command invokes the VirutalBox command VirtualManage to add a port forwarding rule to the VM named, panamax-vm
. The rule created is named rule1
, the protocol is set to tcp
and the port forwarding is set to 8997
from the local machine to 8080
to match the port on the CoreOS host.
NOTE: The empty values between the ports is intentional. Be sure to add the ,,
around the local host port to ensure the mapping works correctly.
By browsing to http://localhost:8997
, your browser is forwarded to port 8080 on the CoreOS host and then forwarded again to port 80 on the container to render the GUI. You can use any free port on your local machine to forward to the CoreOS host.
###Port Forwarding via the VirtualBox GUI The second method to set port forwarding is via the VirtualBox GUI. Follow these steps to enable port forwarding to your CoreOS host:
- Open the VirtualBox GUI on your local machine. Should be available in your Application directory.
- Find the
panamax-vm
in the list of virtual machines and select Settings from the top nav - Click on the Network icon on the top nav
- Select Port Forwarding
- Click the Add rule icon on the top right and fill in your Host port, 8997, and your Guest port, 8080.
- Click OK and OK and the forward is set
By browsing to http://localhost:8997
, your browser is forwarded to port 8080 on the CoreOS host and then forwarded again to port 80 on the container to render the GUI. You can use any free port on your local machine to forward to the CoreOS host.
- The Panamax project is provided under the Apache 2.0 license by CenturyLink