You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@apache.org on 2001/10/04 22:00:53 UTC

cvs commit: httpd-2.0/server core.c listen.c

rbb         01/10/04 13:00:53

  Modified:    .        CHANGES
               docs/conf httpd-std.conf
               docs/manual/mod core.html mpm_common.html
               server   core.c listen.c
  Log:
  Remove the Port directive.  In it's place, the Listen directive
  is now a required directive, which tells Apache what port to
  listen on.  The ServerName directive has also been extended
  to accept an optional port.  If the port is specified to the
  ServerName, the server will report that port whenever it
  reports the port that it is listening on.  This change was
  made to ease configuration errors that stem from having a Port
  directive, and a Listen directive.  In that situation, the server
  would only listen to the port specified by the Listen command,
  which caused a lot of confusion to users.
  
  Revision  Changes    Path
  1.380     +11 -0     httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.379
  retrieving revision 1.380
  diff -u -r1.379 -r1.380
  --- CHANGES	2001/10/04 19:42:43	1.379
  +++ CHANGES	2001/10/04 20:00:52	1.380
  @@ -1,5 +1,16 @@
   Changes with Apache 2.0.26-dev
   
  +  *) Remove the Port directive.  In it's place, the Listen directive
  +     is now a required directive, which tells Apache what port to
  +     listen on.  The ServerName directive has also been extended
  +     to accept an optional port.  If the port is specified to the
  +     ServerName, the server will report that port whenever it
  +     reports the port that it is listening on.  This change was
  +     made to ease configuration errors that stem from having a Port
  +     directive, and a Listen directive.  In that situation, the server
  +     would only listen to the port specified by the Listen command,
  +     which caused a lot of confusion to users.  [Ryan Bloom]
  +
     *) Added mod_mime_magic, mod_unique_id and mod_vhost_alias to the Win32
        build, as loadable modules.  [William Rowe]
   
  
  
  
  1.53      +1 -7      httpd-2.0/docs/conf/httpd-std.conf
  
  Index: httpd-std.conf
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/docs/conf/httpd-std.conf,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- httpd-std.conf	2001/10/03 18:56:38	1.52
  +++ httpd-std.conf	2001/10/04 20:00:53	1.53
  @@ -231,12 +231,6 @@
   #
   
   #
  -# Port: The port to which the standalone server listens. For
  -# ports < 1023, you will need httpd to be run as root initially.
  -#
  -Port @@Port@@
  -
  -#
   # If you wish httpd to run as a different user or group, you must run
   # httpd as root initially and it will switch.  
   #
  @@ -270,7 +264,7 @@
   # You will have to access it by its address (e.g., http://123.45.67.89/)
   # anyway, and this will make redirections work in a sensible way.
   #
  -#ServerName new.host.name
  +#ServerName new.host.name:80
   
   #
   # DocumentRoot: The directory out of which you will serve your
  
  
  
  1.198     +8 -70     httpd-2.0/docs/manual/mod/core.html
  
  Index: core.html
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/docs/manual/mod/core.html,v
  retrieving revision 1.197
  retrieving revision 1.198
  diff -u -r1.197 -r1.198
  --- core.html	2001/09/07 01:49:03	1.197
  +++ core.html	2001/10/04 20:00:53	1.198
  @@ -100,8 +100,6 @@
   
         <li><a href="#options">Options</a></li>
   
  -      <li><a href="#port">Port</a></li>
  -
         <li><a href="#require">Require</a></li>
   
         <li><a href="#rlimitcpu">RLimitCPU</a></li>
  @@ -1907,72 +1905,6 @@
       <code>All</code>.</p>
       <hr />
   
  -    <h2><a id="port" name="port">Port directive</a></h2>
  -    <!--%plaintext &lt;?INDEX {\tt Port} directive&gt; -->
  -    <a href="directive-dict.html#Syntax"
  -    rel="Help"><strong>Syntax:</strong></a> Port
  -    <em>number</em><br />
  -     <a href="directive-dict.html#Default"
  -    rel="Help"><strong>Default:</strong></a> <code>Port
  -    80</code><br />
  -     <a href="directive-dict.html#Context"
  -    rel="Help"><strong>Context:</strong></a> server config<br />
  -     <a href="directive-dict.html#Status"
  -    rel="Help"><strong>Status:</strong></a> core 
  -
  -    <p><em>Number</em> is a number from 0 to 65535; some port
  -    numbers (especially below 1024) are reserved for particular
  -    protocols. See <code>/etc/services</code> for a list of some
  -    defined ports; the standard port for the http protocol is
  -    80.</p>
  -
  -    <p>The Port directive has two behaviors, the first of which is
  -    necessary for NCSA backwards compatibility (and which is
  -    confusing in the context of Apache).</p>
  -
  -    <ul>
  -      <li>In the absence of any <a
  -      href="mpm_common.html#listen">Listen</a> directives
  -      specifying a port number, a Port directive given in the "main
  -      server" (<em>i.e.</em>, outside any <a
  -      href="#virtualhost">&lt;VirtualHost&gt;</a> section) sets the
  -      network port on which the server listens. If there are any
  -      Listen directives specifying <code>:number</code> then Port
  -      has no effect on what address the server listens at.</li>
  -
  -      <li>The Port directive sets the <code>SERVER_PORT</code>
  -      environment variable (for <a href="mod_cgi.html">CGI</a> and
  -      <a href="mod_include.html">SSI</a>), and is used when the
  -      server must generate a URL that refers to itself (for example
  -      when creating an external redirect to itself). This behaviour
  -      is modified by <a
  -      href="#usecanonicalname">UseCanonicalName</a>.</li>
  -    </ul>
  -    The primary behavior of Port should be considered to be similar
  -    to that of the <a href="#servername">ServerName</a> directive.
  -    The ServerName and Port together specify what you consider to
  -    be the <em>canonical</em> address of the server. (See also <a
  -    href="#usecanonicalname">UseCanonicalName</a>.) 
  -
  -    <p>Port 80 is one of Unix's special ports. All ports numbered
  -    below 1024 are reserved for system use, <em>i.e.</em>, regular
  -    (non-root) users cannot make use of them; instead they can only
  -    use higher port numbers. To use port 80, you must start the
  -    server from the root account. After binding to the port and
  -    before accepting requests, Apache will change to a low
  -    privileged user as set by the <a
  -    href="mpm_common.html#user">User directive</a>.</p>
  -
  -    <p>If you cannot use port 80, choose any other unused port.
  -    Non-root users will have to choose a port number higher than
  -    1023, such as 8000.</p>
  -
  -    <p>SECURITY: if you do start the server as root, be sure not to
  -    set <a href="mpm_common.html#user">User</a> to root. If you run
  -    the server as root whilst handling connections, your site may
  -    be open to a major security attack.</p>
  -    <hr />
  -
       <h2><a id="require" name="require">Require directive</a></h2>
       <!--%plaintext &lt;?INDEX {\tt Require} directive&gt; -->
       <a href="directive-dict.html#Syntax"
  @@ -2274,7 +2206,7 @@
       <!--%plaintext &lt;?INDEX {\tt ServerName} directive&gt; -->
       <a href="directive-dict.html#Syntax"
       rel="Help"><strong>Syntax:</strong></a> ServerName
  -    <em>fully-qualified-domain-name</em> <br />
  +    <em>fully-qualified-domain-name:port</em> <br />
        <a href="directive-dict.html#Context"
       rel="Help"><strong>Context:</strong></a> server config, virtual
       host<br />
  @@ -2288,7 +2220,7 @@
       return the preferred hostname. For example:</p>
   
       <blockquote>
  -      <code>ServerName www.example.com</code>
  +      <code>ServerName www.example.com:80</code>
       </blockquote>
       would be used if the canonical (main) name of the actual
       machine were <code>simple.example.com</code>. 
  @@ -2299,6 +2231,12 @@
       href="#virtualhost"><code>&lt;VirtualHost&gt;</code></a>
       section specifies what hostname must appear in the request's
       <code>Host:</code> header to match this virtual host.</p>
  +
  +    <p>This directive now takes allows a port to be added to the
  +    server name.  This allows an admin to assign the canonical
  +    port at the same time that the canonical name is assigned.
  +    The Port directive, which used to perform this role, has also
  +    been removed, easing configuration for all users. 
   
       <p><strong>See Also</strong>:<br />
        <a href="../dns-caveats.html">DNS Issues</a><br />
  
  
  
  1.14      +4 -3      httpd-2.0/docs/manual/mod/mpm_common.html
  
  Index: mpm_common.html
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/docs/manual/mod/mpm_common.html,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- mpm_common.html	2001/09/22 19:36:01	1.13
  +++ mpm_common.html	2001/10/04 20:00:53	1.14
  @@ -208,9 +208,10 @@
   
       <p>The Listen directive instructs Apache to listen to only
       specific IP addresses or ports; by default it responds to
  -    requests on all IP interfaces, but only on the port given by
  -    the <code><a href="core.html#port">Port</a></code>
  -    directive.</p>
  +    requests on all IP interfaces. The Listen directive is now
  +    a required directive. If it is not in the config file, the
  +    server will fail to start. This is a change from previous
  +    versions of Apache.
   
       <p>The Listen directive tells the server to accept incoming
       requests on the specified port or address-and-port combination.
  
  
  
  1.65      +18 -6     httpd-2.0/server/core.c
  
  Index: core.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/core.c,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- core.c	2001/09/29 08:33:02	1.64
  +++ core.c	2001/10/04 20:00:53	1.65
  @@ -1603,15 +1603,27 @@
       return NULL;
   }
   
  -static const char *server_port(cmd_parms *cmd, void *dummy, const char *arg)
  +static const char *server_hostname_port(cmd_parms *cmd, void *dummy, const char *arg)
   {
       const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
  +    const char *portstr;
  +    const char *server;
       int port;
   
       if (err != NULL) {
   	return err;
       }
  -    port = atoi(arg);
  +    portstr = ap_strchr_c(arg, ':');
  +    if (portstr) {
  +        cmd->server->server_hostname = apr_pstrndup(cmd->pool, arg, 
  +                                                    portstr - arg);
  +        portstr++;
  +        port = atoi(portstr);
  +    }
  +    else {
  +        cmd->server->server_hostname = apr_pstrdup(cmd->pool, arg);
  +        port = 80;
  +    }
       if (port <= 0 || port >= 65536) { /* 65536 == 1<<16 */
   	return apr_pstrcat(cmd->temp_pool, "The port number \"", arg, 
   			  "\" is outside the appropriate range "
  @@ -2411,7 +2423,8 @@
   
   /* Old server config file commands */
   
  -AP_INIT_TAKE1("Port", server_port, NULL, RSRC_CONF, "A TCP port number"),
  +AP_INIT_TAKE1("Port", ap_set_deprecated, NULL, RSRC_CONF, 
  +  "Port was replaced with Listen in Apache 2.0"),
   AP_INIT_TAKE1("HostnameLookups", set_hostname_lookups, NULL,
     ACCESS_CONF|RSRC_CONF,
     "\"on\" to enable, \"off\" to disable reverse DNS lookups, or \"double\" to "
  @@ -2419,9 +2432,8 @@
   AP_INIT_TAKE1("ServerAdmin", set_server_string_slot,
     (void *)APR_XtOffsetOf (server_rec, server_admin), RSRC_CONF,
     "The email address of the server administrator"),
  -AP_INIT_TAKE1("ServerName", set_server_string_slot,
  -  (void *)APR_XtOffsetOf (server_rec, server_hostname), RSRC_CONF,
  -  "The hostname of the server"),
  +AP_INIT_TAKE1("ServerName", server_hostname_port, NULL, RSRC_CONF,
  +  "The hostname and port of the server"),
   AP_INIT_TAKE1("ServerSignature", set_signature_flag, NULL, OR_ALL,
     "En-/disable server signature (on|off|email)"),
   AP_INIT_TAKE1("ServerRoot", set_server_root, NULL, RSRC_CONF,
  
  
  
  1.62      +4 -5      httpd-2.0/server/listen.c
  
  Index: listen.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/listen.c,v
  retrieving revision 1.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- listen.c	2001/08/13 04:57:34	1.61
  +++ listen.c	2001/10/04 20:00:53	1.62
  @@ -273,11 +273,10 @@
       ap_listen_rec *next;
       int num_open;
   
  -    /* allocate a default listener if necessary */
  -    if (ap_listeners == NULL) {
  -	alloc_listener(process, NULL, (apr_port_t)(port ? port : DEFAULT_HTTP_PORT));
  -    }
  -
  +    /* Don't allocate a default listener.  If we need to listen to a
  +     * port, then the user needs to have a Listen directive in their
  +     * config file.
  +     */
       num_open = 0;
       for (lr = ap_listeners; lr; lr = lr->next) {
   	if (lr->active) {