-1

Let me start by saying I'm not a sys admin but I've been tasked with creating a new apache web server. For now, I'm just trying to install the base package, confirm it's working and communicating on the network... and then try to set up the apache2-ldap module.

Problem

When I try to reach the new server from a browser on a remote machine by using it's ip address (let's say for example http://10.23.23.23) , I get ERR_CONNECTION_TIMED_OUT message.

How I did the Install

  1. I did an "apk add apache2". This created the default conf file and the folder / file in /var/www/localhost/htdocs/index.html
  2. Then I edited the /etc/hosts file so it looks like this:
mytestserver:/# cat /etc/hosts
127.0.0.1       localhost
127.0.0.1       webdev.<mydomainname>
  1. I edited /etc/apache2/httpd.conf and added the ServerName. These are some of the entries I have in the httpd.conf file right now:
   ServerName localhost
   DocumentRoot "/var/www/localhost/htdocs"    

   <Directory />
        Options FollowSymLinks
        AllowOverride none
    #    Require all denied
    #    Order allow,deny
    #    Deny from all
    </Directory>

    <Directory "/var/www/localhost/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride All
    #    Require all granted
        Order allow,deny
        Allow from all
    </Directory>
  1. Then I restarted apache and made sure it starts without any errors.

What I've Tried / Checked So Far

  1. Made sure the service is running: mytestserver:/# wget rc-status Runlevel: default iptables [ started ] networking [ started ] snmpd [ started ] sshd [ started ] apache2 [ started ]

  2. Tried to reach the server from the server itself using wget (not sure if it's a good idea but i thought it would prove that http traffic is working this server...) As you can see from the example below, it worked.

mytestserver:/# wget localhost
Connecting to localhost (127.0.0.1:80)
index.html           100% |********************************************************************************************************************|    45   0:00:00 ETA

I stopped apache on the server and retried the same wget test and it fails:

Connecting to localhost (127.0.0.1:80)
wget: can't connect to remote host (127.0.0.1): Connection refused

Which, in my mind proves that apache itself is working on this server.

  1. Checked netstat for the port status:
mytestserver:/# netstat -lnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      213/sshd
tcp        0      0 :::80                   :::*                    LISTEN      5599/httpd
tcp        0      0 :::22                   :::*                    LISTEN      213/sshd
udp        0      0 0.0.0.0:161             0.0.0.0:*                           2305/snmpd
Active UNIX domain sockets (only servers)
  1. As I am trying to open the browser on the remote machine, I did a tail -f on the apache error log. But nothing is showing up. Same goes for the access.log... which tells me that it's not hitting the server at all?

Not sure what else to check. I'm currently reading other posts here to see if I can find something to point me in the right direction. But if you have any tips, I'd appreciate it. Thanks.

  • 3
    What host name are you trying to connect to? Are you aware that localhost/127.0.0.1 is always the address of a computer itself so if you try to connect to localhost on any computer, you try a connection to itself and not to some remote server... – Sven Mar 29 '17 at 17:41
  • @Sven yes, i do realize that. i did that on purpose to see if wget would work.... thinking that would prove that apache was running. From remote machines, I'm using the iP address of the apache server. i thought that would be clear by the fact that the prompt in my samples are from the web server itself. But i will add a comment to clarify my question... and clarify the tests i'm running – dot Mar 29 '17 at 20:43
1

Based on your description it sounds like you're using localhost as the server name. That's always the local computer as pointed out in the comments. You would need to 1) configure Apache to listen on a name other than localhost (it appears you were trying to use webdev), 2) add a record to your DNS server on your local network called webdev to point at the IP of mytestserver, or alternatively add a record to the HOST file pointing to the IP of that server on the test client machine (not 127.0.0.1), and 3) make sure your firewall is open to accept connections on port 80. You could also simply request the site via the network IP of the mytestserver machine (also not 127.0.0.1, check ifconfig) if that's the default site for your apache configuration.

0

The problem was the apache conf. Port 80 was open ... but listening on :::80
I changed the "Listen" address in the config from this:

Listen 80

to this:

Listen 0.0.0.0:80

And now it works. I can launch the site from the remote machine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.