I run this command inside my vagrant instance:
printf 'HTTP/1.1 302 Moved\r\nLocation: https://www.eff.org/' | nc -l 2345
On my host computer, I want to access <ip of my vagrant server>:2345
and be redirected to https://www.eff.org/.
Redirect does not happen, the browser just keeps loading.
My Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.network "public_network"
end
How to set up Vagrantfile and determine the IP address of the vagrant Linux server, to use in the browser on the host machine using port 2345?
I have tried:
curl ifconfig.me
, got:46.128.200.193
hostname -i
, got:2a02:2455:25f:e000:a00:27ff:febd:cd6c%4
10.0.2.15
192.168.33.10
192.168.0.16
ifconfig
, got:
eth0 Link encap:Ethernet HWaddr 08:00:27:5f:bb:e6
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe5f:bbe6/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:815 errors:0 dropped:0 overruns:0 frame:0
TX packets:590 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:83632 (83.6 KB) TX bytes:80621 (80.6 KB)
eth1 Link encap:Ethernet HWaddr 08:00:27:c0:4e:f3
inet addr:192.168.33.10 Bcast:192.168.33.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fec0:4ef3/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:819 (819.0 B) TX bytes:2040 (2.0 KB)
eth2 Link encap:Ethernet HWaddr 08:00:27:bd:cd:6c
inet addr:192.168.0.16 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: 2a02:2455:25f:e000:a00:27ff:febd:cd6c/64 Scope:Global
inet6 addr: fe80::a00:27ff:febd:cd6c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:412 errors:0 dropped:0 overruns:0 frame:0
TX packets:103 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:31706 (31.7 KB) TX bytes:8356 (8.3 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:888 (888.0 B) TX bytes:888 (888.0 B)
On my host machine, I have tried accessing in the browser:
192.168.33.10:2345
, got:
GET / HTTP/1.1
Host: 192.168.33.10:2345
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:77.0) Gecko/20100101 Firefox/77.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Upgrade-Insecure-Requests: 1
10.0.2.15:2345
, got nothing46.128.200.193:2345
, got nothing
But no setup of Vagrantfile and combination of ip addresses with port 2345 have redirected me to eff.org so far.