0

I have a strange problem with my web server throwing the above error from a local machine on my network. If I access the remote server through its ip address, 192.168.0.2, I get the default index.html apache2 page. If I access it through the name of the server, server-01.jjnetwork I get the error. I don't get any errors logged, or any access logged from trying the server name. I'm unsure how to find out where the problem lies. I'm running Ubuntu 14.04 Server, apache2 and using dnsmasq for dhcp and dns. All are the latest versions from the ubuntu repositories.

Here are some steps I've taken to diagnose the problem. My apologies if there's too much code, I'm just not sure where the problem lies;

The headers for the request are;

Request URL:http://server-01.jjnetwork/
Request Method:GET
Status Code:403 Forbidden
Remote Address:127.0.0.1:80

This seems odd, I'm not sure why it's getting the remote address as 127.0.1.1 This makes me think it may be a dns problem.

However, from my local terminal, I can ping the server thus;

joemiller@joemiller:/ > ping server-01.jjnetwork
PING server-01.jjnetwork (192.168.0.2) 56(84) bytes of data.
64 bytes from server-01.jjnetwork (192.168.0.2): icmp_seq=1 ttl=64 time=1.53 ms
64 bytes from server-01.jjnetwork (192.168.0.2): icmp_seq=2 ttl=64 time=2.02 ms
64 bytes from server-01.jjnetwork (192.168.0.2): icmp_seq=3 ttl=64 time=1.49 ms
64 bytes from server-01.jjnetwork (192.168.0.2): icmp_seq=4 ttl=64 time=2.02 ms
^C
--- server-01.jjnetwork ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 1.496/1.767/2.020/0.254 ms

So I assume the domain name is being correctly resolved. I've checked this via a dig query, directed at the server;

joemiller@joemiller:/ > nslookup server-01.jjnetwork 192.168.0.2
Server:         192.168.0.2
Address:        192.168.0.2#53

Name:   server-01.jjnetwork
Address: 192.168.0.2
Name:   server-01.jjnetwork
Address: 127.0.1.1
Name:   server-01.jjnetwork
Address: 127.0.0.1

My hosts file contains this;

root@server-01:/home/joemiller# grep -o '^[^#]*' /etc/hosts
127.0.0.1       localhost server-01
127.0.1.1       server-01
192.168.0.2       server-01
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Here is my dnsmasq configuration;

root@server-01:/home/joemiller# grep -o '^[^#]*' /etc/dnsmasq.conf
domain-needed
bogus-priv
resolv-file=/etc/resolv.dnsmasq.conf
local=/jjnetwork/
interface=eth0
listen-address=127.0.0.1
listen-address=192.168.0.2
bind-interfaces
expand-hosts
domain=jjnetwork
dhcp-range=192.168.0.10,192.168.0.150,120h
dhcp-authoritative
log-dhcp

The server 192.168.0.2 is getting its ip address statically, which I think may be part of the problem. My interfaces file looks like this;

root@server-01:/home/joemiller# grep -o '^[^#]*' /etc/network/interfaces
auto lo
iface lo inet loopback
auto ppp0
iface ppp0 inet wvdial
        provider Defaults
auto eth0
iface eth0 inet static
        address 192.168.0.2
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255

Can anyone shed any light on what the problem might be, and what I can do to fix it?

4
  • Try running sudo chown www-data:www-data /var/www/html -R Also, can you post your vhost? (Stored in /etc/apache2/sites-enabled or /etc/apache2/sites-available) Jan 21, 2016 at 21:11
  • Thanks @Grammargeek for looking at my problem. chowning the files didn't make any difference. I don't think it's a permissions problem, as I an see the default index.html page via the ip address. I don't have a vhosts file, just the default installation so far. I've copied the 000-default config into my answer if it helps, but there's not much in it!
    – Joe Miller
    Jan 21, 2016 at 21:26
  • Did you try removing the other 2 IPs of server-01 from the hosts file?
    – user23013
    Jan 21, 2016 at 21:31
  • Thanks @user23013 I've removed 127.0.1.1 and 192.168.0.2 from hosts, reloaded dnsmasq and networking, but no change
    – Joe Miller
    Jan 21, 2016 at 21:36

1 Answer 1

0

I found the solution to this. The problem lies in my /etc/hosts file on the server. I've changed it to this, and everything now works fine.

127.0.0.1       localhost
127.0.1.1       localhost
192.168.0.2       server-01.jjnetwork       server-01
# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

dnsmasq seems to have been returning the first record it finds as the result of a dns query. In my case, it was 127.0.1.1 which the local box seems to have been re-routing to 127.0.0.1, hence the error.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .