[olug] apache not reachable

Tim & Alethea Larson thelarsons3 at cox.net
Fri Mar 11 05:35:33 UTC 2005


Christopher Cashell wrote:
> When you say "except from the localhost", what exactly do you mean?  Do
> you mean you are connecting to localhost (127.0.0.1), or connecting to
> your network interface from that local machine?
> 
> What happens when you try to connect to the ethernet interface, as
> opposed to localhost, from the local machine?

I can connect to the interface, localhost, and 127.0.0.1 from the local 
machine.  Connecting to its IP from anywhere else is refused.

> Have you verified that it is listening on the proper interfaces/IPs?

Yup.  It's listening to port 80.

> I wouldn't think so, but it's hard to say.  You may want to ensure that
> there are no passwords or sensitive information and try posting your
> apache config and initscript, either somewhere web accessible, or to the
> list.

Here is the init script.  I tried changing the apachectl and httpd 
reference to the actual file rather than the symlink, but it didn't help.

#!/bin/bash
#
# Startup script for the Apache Web Server
#
# chkconfig: 35 85 15
# description: Apache is a World Wide Web server.  It is used to serve \
#              HTML files and CGI.
# processname: httpd
# pidfile: /var/run/httpd.pid
# config: /etc/httpd/conf/httpd.conf

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
         . /etc/sysconfig/httpd
fi

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/sbin/apachectl
httpd=${HTTPD-/usr/sbin/httpd}
prog=httpd
RETVAL=0

# check for 1.3 configuration
check13 () {
         CONFFILE=/etc/httpd/conf/httpd.conf
         GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|"
         GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|"
         GONE="${GONE}AccessConfig|ResourceConfig)"
         if grep -Eiq "^[[:space:]]*($GONE)" $CONFFILE; then
                 echo
                 echo 1>&2 " Apache 1.3 configuration directives found"
                 echo 1>&2 " please read 
/usr/share/doc/httpd-2.0.40/migration.ht
ml"
                 failure "Apache 1.3 config directives test"
                 echo
                 exit 1
         fi
}

# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure.  So we just do it the way init scripts
# are expected to behave here.
start() {
         echo -n $"Starting $prog: "
#        check13 || exit 1
         daemon $httpd $OPTIONS
         RETVAL=$?
         echo
         [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
         return $RETVAL
}
stop() {
         echo -n $"Stopping $prog: "
         killproc $httpd
         RETVAL=$?
         echo
         [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid
}
reload() {
         echo -n $"Reloading $prog: "
#       check13 || exit 1
         killproc $httpd -HUP
         RETVAL=$?
         echo
}

# See how we were called.
case "$1" in
   start)
         start
         ;;
   stop)
         stop
         ;;
   status)
         status $httpd
         RETVAL=$?
         ;;
   restart)
         stop
         start
         ;;
   condrestart)
         if [ -f /var/run/httpd.pid ] ; then
                 stop
                 start
         fi
         ;;
   reload)
         reload
         ;;
   graceful|help|configtest|fullstatus)
         $apachectl $@
         RETVAL=$?
         ;;
   *)
         echo $"Usage: $prog 
{start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
         exit 1
esac

exit $RETVAL

Here's the Apache config file.  I did try putting the default one back 
in, but it exhibited the same behavior: I got the default Apache page 
when on the local machine, but couldn't connect from anywhere else.  All 
I've changed from my old server is the server name and commenting out 
the IPv6 listen directive.

#
# Based upon the NCSA server configuration files originally by Rob McCool.
#
# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs-2.0/> for detailed information about
# the directives.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.
#
# The configuration directives are grouped into three basic sections:
#  1. Directives that control the operation of the Apache server process 
as a
#     whole (the 'global environment').
#  2. Directives that define the parameters of the 'main' or 'default' 
server,
#     which responds to requests that aren't handled by a virtual host.
#     These directives also provide default values for the settings
#     of all virtual hosts.
#  3. Settings for virtual hosts, which allow Web requests to be sent to
#     different IP addresses or hostnames and have them handled by the
#     same Apache server process.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
# with ServerRoot set to "/usr/local/apache2" will be interpreted by the
# server as "/usr/local/apache2/logs/foo.log".
#

### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
Listen 0.0.0.0:80
#Listen [::]:80

#UserDir public_html
Options IncludesNoExec FollowSymLinks MultiViews
DirectoryIndex index.jsp index.xhtml index.shtml index.html
#ServerRoot /usr/local/apache2
#ErrorLog logs/error_log
#TypesConfig conf/mime.types
PIDFile /var/run/httpd.pid

### Section 2: 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

<IfModule !mpm_winnt.c>
<IfModule !mpm_netware.c>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
#  . On SCO (ODT 3) use "User nouser" and "Group nogroup".
#  . On HPUX you may not be able to use shared memory as nobody, and the
#    suggested workaround is to create a user www and use that user.
#  NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET)
#  when the value of (unsigned)Group is above 60000;
#  don't use Group #-1 on these systems!
#
User apache
Group apache
</IfModule>
</IfModule>

#
# ServerName gives the name and port that the server uses to identify 
itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work.  See also the UseCanonicalName directive.
#
# If your host doesn't have a registered DNS name, enter its IP address 
here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#
ServerName charliebrown.christtrek.org

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" 
combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# You need to enable mod_logio.c to use %I and %O
#LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" 
%I %O" combinedio

#
# The location and format of the access logfile.
# If you do not define any access logfiles within a <VirtualHost>
# container, they will be logged here.  Contrariwise, if you *do*
# define per-<VirtualHost> access logfiles, transactions will be
# logged therein and *not* in this file.
#
CustomLog logs/access.log combined

#
# Aliases: Add here as many aliases as you need (with no limit). The 
format is
# Alias fakename realname
#
# Note that if you include a trailing / on fakename then the server will
# require it to be present in the URL.  So "/icons" isn't aliased in this
# example, only "/icons/".  If the fakename is slash-terminated, then the
# realname must also be slash terminated, and if the fakename omits the
# trailing slash, the realname must also omit it.
#
# We include the /icons/ alias for FancyIndexed directory listings.  If you
# do not use FancyIndexing, you may comment this out.
#
Alias /apacheicons/ "/usr/local/apache2/icons/"

<Directory "/usr/local/apache2/icons">
     Options Indexes MultiViews
     AllowOverride None
     Order allow,deny
     Allow from all
</Directory>

#
# AddIcon* directives tell the server which icon to show for different
# files or filename extensions.  These are only displayed for
# FancyIndexed directories.
#
AddIconByEncoding (CMP,/apacheicons/compressed.png) x-compress x-gzip

AddIconByType (TXT,/apacheicons/text.png) text/*
AddIconByType (IMG,/apacheicons/image2.png) image/*
AddIconByType (SND,/apacheicons/sound2.png) audio/*
AddIconByType (VID,/apacheicons/movie.png) video/*

#
# Filters allow you to process content before it is sent to the client.
#
# To parse .shtml files for server-side includes (SSI):
# (You will also need to add "Includes" to the "Options" directive.)
#
AddOutputFilter INCLUDES shtml xhtml

### Section 3: Virtual Hosts
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry 
about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs-2.0/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
<VirtualHost *:80>
     ServerAdmin webmaster at christtrek.org
     DocumentRoot /home/websites/christtrek.org
     ServerName christtrek.dyndns.org
     ErrorLog "|/usr/local/apache2/bin/rotatelogs 
/home/websites/logs/christtrek.org/error.log%Y%m%d 2629800"
     CustomLog "|/usr/local/apache2/bin/rotatelogs 
/home/websites/logs/christtrek.org/access.log%Y%m%d 604800" combined
     Options +Indexes
     IndexOptions +FancyIndexing +NameWidth=*
     UserDir public_html
</VirtualHost>

<VirtualHost *:80>
     ServerAdmin webmaster at cpne.org
     DocumentRoot /home/websites/cpne.org
     ServerName cpne.dyndns.org
     ErrorLog "|/usr/local/apache2/bin/rotatelogs 
/home/websites/logs/cpne.org/error.log%Y%m%d 2629800"
     CustomLog "|/usr/local/apache2/bin/rotatelogs 
/home/websites/logs/cpne.org/access.log%Y%m%d 604800" combined
     UserDir disabled
</VirtualHost>


-- 
Tim & Alethea
christtrek.org



More information about the OLUG mailing list