Error empty response when accessing apache virtual host from another computer on local network
So, for those new to Linux, I followed some tips and tricks from SO etc.
I can't access the locale website from another computer (Mac) on the LAN.
My server: Apache Server version: Apache/2.4.7 (Ubuntu)
(Linux Mint 17.2 Rafaela).
I have the following virtual host file:
<VirtualHost *:80>
ServerName toesslab-new
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/toesslab-new
<Directory /var/www/html/toesslab-new>
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 ::1
Allow from 127.0.0.1 ::1
Allow from localhost
Allow from 192.168
Allow from 10
Satisfy Any
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I also tried <VirtualHost *>
without success.
The virtual host works fine on my computer by calling the following command http://toesslab-new/
.
Also, I adapted it /private/etc/hosts
on another computer that is on the Mac OSX Yosemite 10.10.5
LAN and connected to the following IP :
en0 -> inetaddr: 192.168.0.12
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
192.168.0.14 toesslab-new
127.0.0.1 toesslab-new
The server's IP is, 127.0.0.1
but I'm not at all sure if this is the IP to use or if I have to get my local IP via wlan :
wlan0 -> inetaddr: 192.168.0.14
So after , I did dscacheutil -flushcache; sudo killall -HUP mDNSResponder
it on the Mac and then naturally service apache2 restart
on the computer.
I won't post all (stupid) attempts, but this is by far the best.
When I'm calling http://toesslab-new/
on a Mac , all of this results in the browser taking a long time to load and then giving me a prompt ERR_EMPTY_RESPONSE
.
By reading my log file (access.log) I don't get any further, it just shows me normal access. The error.log entries are obsolete, so none are used.
When I googled this, I didn't go any further.
- What IP do I have to enter in the Mac's hosts file?
- Is my virtual host file correct?
- What else am I missing?
After updating @Trel's answer , I modified the hosts file as follows with no luck:
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
#127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
192.168.0.14 toesslab-new
#127.0.0.1 toesslab-new
If you do it on ip route get 1 | awk '{print $NF; exit}'
my computer 192.168.0.14
, it has to be the IP you want to use on another computer's hosts file, doesn't it?
ifconfig
Output from my machine:
eth0 Link encap:Ethernet HWaddr 50:46:5d:09:34:b7
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
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:485452 errors:0 dropped:0 overruns:0 frame:0
TX packets:485452 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:333999317 (333.9 MB) TX bytes:333999317 (333.9 MB)
wlan0 Link encap:Ethernet HWaddr 90:4c:e5:55:94:09
inet addr:192.168.0.14 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::924c:e5ff:fe55:9409/64 Scope:Link
inet6 addr: 2a02:aa15:c300:7100:b8ba:22a8:ddab:3734/64 Scope:Global
inet6 addr: 2a02:aa15:c300:7100::1/128 Scope:Global
inet6 addr: 2a02:aa15:c300:7100:e49d:c7a6:20c2:7fa3/64 Scope:Global
inet6 addr: 2a02:aa15:c300:7100:b001:78b7:b5d7:7a2a/64 Scope:Global
inet6 addr: 2a02:aa15:c300:7100:924c:e5ff:fe55:9409/64 Scope:Global
inet6 addr: 2a02:aa15:c300:7100:cd97:9496:59f8:3ccd/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2998367 errors:0 dropped:0 overruns:0 frame:0
TX packets:2541043 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2181346334 (2.1 GB) TX bytes:395504593 (395.5 MB)
ifconfig
Output from another machine (Mac):
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff000000
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=1<PERFORMNUD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
ether a8:20:66:52:48:9d
inet6 fe80::aa20:66ff:fe52:489d%en0 prefixlen 64 scopeid 0x4
inet6 2a02:aa15:c300:7100:aa20:66ff:fe52:489d prefixlen 64 autoconf
inet6 2a02:aa15:c300:7100:8518:985d:c778:d6c8 prefixlen 64 autoconf temporary
inet6 2a02:aa15:c300:7100::3 prefixlen 64 dynamic
nd6 options=1<PERFORMNUD>
media: autoselect (1000baseT <full-duplex,flow-control,energy-efficient-ethernet>)
status: active
en1: flags=8823<UP,BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 1500
ether 8c:2d:aa:45:1b:f1
nd6 options=1<PERFORMNUD>
media: autoselect (<unknown type>)
status: inactive
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:13:dd:f8:60
media: autoselect <full-duplex>
status: inactive
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=60<TSO4,TSO6>
ether 32:00:13:dd:f8:61
media: autoselect <full-duplex>
status: inactive
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=63<RXCSUM,TXCSUM,TSO4,TSO6>
ether aa:20:66:25:19:00
Configuration:
id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
ipfilter disabled flags 0x2
member: en2 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 6 priority 0 path cost 0
member: en3 flags=3<LEARNING,DISCOVER>
ifmaxaddr 0 port 7 priority 0 path cost 0
nd6 options=1<PERFORMNUD>
media: <unknown type>
status: inactive
p2p0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 2304
ether 0e:2d:aa:45:1b:f1
media: autoselect
status: inactive
awdl0: flags=8902<BROADCAST,PROMISC,SIMPLEX,MULTICAST> mtu 1452
ether 26:5e:59:3d:a2:35
nd6 options=1<PERFORMNUD>
media: autoselect
status: inactive
127.0.0.1 is the local address
If you're 127.0.0.1 toesslab-new
on the computer trying to access FROM, tell it to use yourself as that hostname.
What is the LAN IP of the server using Apache? If you are editing the hosts file to hardcode the entry, then this is the IP you need to enter.
Also, as mentioned in the chat, make sure that the firewall (UFW by default for Ubunut and Mint) allows port 80. You can open that port for use with TCP using the command sudo ufw allow 80/tcp
.