akosut 96/03/29 23:16:45
Modified: src CHANGES http_config.c http_config.h http_core.c http_main.c http_protocol.c httpd.h Log: Take the <HostAlias> functionality added earlier, and fold it back into <VirtualHost>. This hopefully makes for a config file that makes more sense, plus it allows for easier transition, since the conf files do not have to be changed. A ServerAlias directive has been added, which goes inside the <VirtualHost> and can provide additional names which that host will recognize itself as. These can include wildcards, e.g. "ServerAlias *.foo.com foo.bar.net foo.com". The canonical name is given by the <VirtualHost> directive or a ServerName. Revision Changes Path 1.17 +6 -4 apache/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apache/src/CHANGES,v retrieving revision 1.16 retrieving revision 1.17 diff -C3 -r1.16 -r1.17 *** CHANGES 1996/03/28 07:59:29 1.16 --- CHANGES 1996/03/30 07:16:39 1.17 *************** *** 1,7 **** ! *) Add <HostAlias> directive, similar to <VirtualHost>, but does not ! require additional IP addresses - instead uses the Host: header sent ! by some (but not all) clients - those that do not will get the normal ! set of documents. Use as: <HostAlias foo.bar.net *.foo.com foo.com> *) Added Status module with preliminary documentation available http://www.apache.org/docs/1.1/mod_status.html --- 1,9 ---- ! *) Modify <VirtualHost> directive to work without the system supporting ! multiple IP addresses. It can now take advantage of the Host: header ! sent by some (but not all) new web browsers (e.g. Netscape 2.0). Those ! that do not support it will get the default documents. More names or ! name patters can be added using the ScriptAlias directive, e.g. ! "ScriptAlias foo.bar.net *.foo.com foo.com" *) Added Status module with preliminary documentation available http://www.apache.org/docs/1.1/mod_status.html 1.9 +2 -32 apache/src/http_config.c Index: http_config.c =================================================================== RCS file: /export/home/cvs/apache/src/http_config.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C3 -r1.8 -r1.9 *** http_config.c 1996/03/28 07:59:30 1.8 --- http_config.c 1996/03/30 07:16:39 1.9 *************** *** 657,694 **** s->next = NULL; s->is_virtual = 1; ! ! s->module_config = create_empty_config (p); ! s->lookup_defaults = create_per_dir_config (p); ! ! return s; ! } ! ! server_rec *init_host_alias (pool *p, char *hostnames) ! { ! server_rec *s = (server_rec *)pcalloc (p, sizeof (server_rec)); ! ! #ifdef RLIMIT_NOFILE ! struct rlimit limits; ! ! getrlimit ( RLIMIT_NOFILE, &limits ); ! if ( limits.rlim_cur < limits.rlim_max ) { ! limits.rlim_cur += 2; ! if ( setrlimit ( RLIMIT_NOFILE, &limits ) < 0 ) ! fprintf (stderr, "Cannot exceed hard limit for open files"); ! } ! #endif ! ! s->server_admin = NULL; ! s->server_hostname = NULL; ! s->error_fname = NULL; ! s->srm_confname = NULL; ! s->access_confname = NULL; ! s->timeout = 0; ! s->names = pstrdup(p, hostnames); ! s->next = NULL; ! ! s->is_virtual = 2; s->module_config = create_empty_config (p); s->lookup_defaults = create_per_dir_config (p); --- 657,664 ---- s->next = NULL; s->is_virtual = 1; ! s->virthost = pstrdup(p, hostname); ! s->names = NULL; s->module_config = create_empty_config (p); s->lookup_defaults = create_per_dir_config (p); 1.4 +0 -1 apache/src/http_config.h Index: http_config.h =================================================================== RCS file: /export/home/cvs/apache/src/http_config.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C3 -r1.3 -r1.4 *** http_config.h 1996/03/28 07:59:30 1.3 --- http_config.h 1996/03/30 07:16:40 1.4 *************** *** 242,248 **** char *srm_command_loop (cmd_parms *parms, void *config); server_rec *init_virtual_host (pool *p, char *hostname); - server_rec *init_host_alias (pool *p, char *hostnames); int is_virtual_server (server_rec *); void process_resource_config(server_rec *s, char *fname, pool *p, pool *ptemp); --- 242,247 ---- 1.8 +3 -41 apache/src/http_core.c Index: http_core.c =================================================================== RCS file: /export/home/cvs/apache/src/http_core.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C3 -r1.7 -r1.8 *** http_core.c 1996/03/28 07:59:30 1.7 --- http_core.c 1996/03/30 07:16:40 1.8 *************** *** 550,594 **** return errmsg; } - char *end_hostalias_magic = "</HostAlias> out of place"; - - char *end_hostalias_section (cmd_parms *cmd, void *dummy) { - return end_hostalias_magic; - } - - char *hostalias_section (cmd_parms *cmd, void *dummy, char *arg) - { - server_rec *main_server = cmd->server, *s; - char *errmsg, *endp = strrchr (arg, '>'); - pool *p = cmd->pool, *ptemp = cmd->temp_pool; - - if (endp) *endp = '\0'; - - if (main_server->is_virtual) - return "<HostAlias> doesn't nest!"; - - s = init_host_alias (p, arg); - s->next = main_server->next; - main_server->next = s; - - cmd->server = s; - errmsg = srm_command_loop (cmd, s->lookup_defaults); - cmd->server = main_server; - - if (s->srm_confname) - process_resource_config (s, s->srm_confname, p, ptemp); - - if (s->access_confname) - process_resource_config (s, s->access_confname, p, ptemp); - - if (errmsg == end_hostalias_magic) { - if (!s->server_hostname) - return "ServerName must be specified in a <HostAlias>"; - return NULL; - } - return errmsg; - } - char *set_server_string_slot (cmd_parms *cmd, void *dummy, char *arg) { /* This one's pretty generic... */ --- 550,555 ---- *************** *** 793,798 **** --- 754,762 ---- { "ResourceConfig", set_server_string_slot, (void *)XtOffsetOf (server_rec, srm_confname), RSRC_CONF, TAKE1, "the filename of the resource config file" }, + { "ServerAlias", set_server_string_slot, + (void *)XtOffsetOf (server_rec, names), RSRC_CONF, RAW_ARGS, + "a name or names alternately used to access the server" }, { "Timeout", set_timeout, NULL, RSRC_CONF, TAKE1, "timeout duration (sec)"}, { "KeepAliveTimeout", set_keep_alive_timeout, NULL, RSRC_CONF, TAKE1, "Keep-Alive timeout duration (sec)"}, { "KeepAlive", set_keep_alive, NULL, RSRC_CONF, TAKE1, "Maximum Keep-Alive requests per connection (0 to disable)" }, *************** *** 812,819 **** "a port number or a numeric IP address and a port number"}, { "<VirtualHost", virtualhost_section, NULL, RSRC_CONF, RAW_ARGS, NULL }, { "</VirtualHost>", end_virtualhost_section, NULL, RSRC_CONF, NO_ARGS, NULL }, - { "<HostAlias", hostalias_section, NULL, RSRC_CONF, RAW_ARGS, NULL }, - { "</HostAlias>", end_hostalias_section, NULL, RSRC_CONF, NO_ARGS, NULL }, { NULL }, }; --- 776,781 ---- 1.16 +17 -4 apache/src/http_main.c Index: http_main.c =================================================================== RCS file: /export/home/cvs/apache/src/http_main.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C3 -r1.15 -r1.16 *** http_main.c 1996/03/29 15:44:32 1.15 --- http_main.c 1996/03/30 07:16:41 1.16 *************** *** 976,995 **** void default_server_hostnames(server_rec *s) { ! struct hostent *h; char *def_hostname; /* Main host first */ if (!s->server_hostname) s->server_hostname = get_local_host(pconf); def_hostname = s->server_hostname; /* Then virtual hosts */ ! for (s = s->next; s; s = s->next) ! if (!s->server_hostname) { ! if (s->host_addr.s_addr == htonl(INADDR_ANY)) s->server_hostname = def_hostname; else { --- 976,1007 ---- void default_server_hostnames(server_rec *s) { ! struct hostent *h, *main; char *def_hostname; + int n; + /* Main host first */ if (!s->server_hostname) s->server_hostname = get_local_host(pconf); def_hostname = s->server_hostname; + main = gethostbyname(def_hostname); /* Then virtual hosts */ ! for (s = s->next; s; s = s->next) { ! /* Check to see if we might be a HTTP/1.1 virtual host - same IP */ ! for (n = 0; main->h_addr_list[n] != NULL; n++) { ! if (s->host_addr.s_addr == ! (((struct in_addr *)(main->h_addr_list[n]))->s_addr)) ! s->is_virtual = 2; ! } ! ! if (!s->server_hostname) { ! if (s->is_virtual == 2) ! s->server_hostname = s->virthost; ! else if (s->host_addr.s_addr == htonl(INADDR_ANY)) s->server_hostname = def_hostname; else { *************** *** 999,1004 **** --- 1011,1017 ---- s->server_hostname = pstrdup (pconf, (char *)h->h_name); } } + } } void abort_connection (conn_rec *c) 1.14 +9 -1 apache/src/http_protocol.c Index: http_protocol.c =================================================================== RCS file: /export/home/cvs/apache/src/http_protocol.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C3 -r1.13 -r1.14 *** http_protocol.c 1996/03/28 07:59:31 1.13 --- http_protocol.c 1996/03/30 07:16:41 1.14 *************** *** 361,367 **** for (s = r->server->next; s; s = s->next) { char *names = s->names; ! if (s->is_virtual != 2) continue; /* No a HostAlias */ while (*names) { char *name = getword_conf (r->pool, &names); --- 361,375 ---- for (s = r->server->next; s; s = s->next) { char *names = s->names; ! if (!strcasecmp(host, s->server_hostname)) { ! r->server = r->connection->server = s; ! if (r->hostlen && !strncmp(r->uri, "http://", 7)) { ! r->uri += r->hostlen; ! parse_uri(r, r->uri); ! } ! } ! ! if (!names) continue; while (*names) { char *name = getword_conf (r->pool, &names); 1.13 +1 -0 apache/src/httpd.h Index: httpd.h =================================================================== RCS file: /export/home/cvs/apache/src/httpd.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C3 -r1.12 -r1.13 *** httpd.h 1996/03/28 07:59:32 1.12 --- httpd.h 1996/03/30 07:16:42 1.13 *************** *** 462,467 **** --- 462,468 ---- int keep_alive; /* Maximum requests per connection */ char *names; /* Wildcarded names for HostAlias servers */ + char *virthost; /* The name given in <VirtualHost> */ }; /* These are more like real hosts than virtual hosts */