Reputation: 14470
I am using Vagrant to manage Ubuntu instance for testing a web application. I am having trouble setting up its login page over https. As the application is using Apache2+php5+mysql. I have setup port forwarding sth like this to access the application from Host machine .
config.vm.network :forwarded_port, guest: 80, host: 8080
When I try to access guest using http://localhost:8080
, it redirect to https://localhost:8080
Which seams reasonable ,but the 8080 port is forwarded to http:80 guest port not to https:43.
so url https://localhost:8080
is half true half a lie . I don't know how to forward https port to guest https port but I wonder what will happen of https://localhost:8080
redirect since that is not valid url is should be ( as I think ) sth like https://localhost:4343
, if https:4343 is forwarded to guest:43. But application is not aware of the ports , it just changes http
with https
(forgive me for the gibberish )
How I setup Vagrant network setting to access guest Apache http:80 and https:43 ports. Can I assigned a static IP to guest instance and use that pleasantly .
regards
using:
Vagrant version 1.1.5
Ubuntu precise64.box
Upvotes: 0
Views: 4851
Reputation: 13920
For your use case, the default Networking mode - NAT is not a good choice because you have multiple ports (at least 80 and 443) to be forwarded.
I recommend using bridged mode so that the guest appears to be a physical host in your LAN and you will be able to access HTTP/HTTPS using its LAN IP. You don't need to do port forwarding (actually you cannot do port forwarding in VirtualBox for bridged mode).
To use bridge mode (Public Network), in your Vagrantfile
add config.vm.network :public_network
into the Vagrant.configure
block and do a vagrant reload
, it should work flawlessly. Use ifconfig -a
to check, a 2nd interface will be added for bridged.
Reference: http://docs.vagrantup.com/v2/networking/public_network.html
Upvotes: 1