From owner-freebsd-hackers Tue Jan 10 19:06:48 1995 Return-Path: hackers-owner Received: (from root@localhost) by freefall.cdrom.com (8.6.9/8.6.6) id TAA14455 for hackers-outgoing; Tue, 10 Jan 1995 19:06:48 -0800 Received: from localhost (localhost [127.0.0.1]) by freefall.cdrom.com (8.6.9/8.6.6) with SMTP id TAA14447 for ; Tue, 10 Jan 1995 19:06:44 -0800 X-Authentication-Warning: freefall.cdrom.com: Host localhost didn't use HELO protocol To: hackers@freefall.cdrom.com Subject: Jordan Hayes: Re: Virtual top-level home pages on the same machine Date: Tue, 10 Jan 1995 19:06:42 -0800 Message-ID: <14444.789793602@freefall.cdrom.com> From: "Jordan K. Hubbard" Sender: hackers-owner@FreeBSD.org Precedence: bulk Anyone interested in this? ------- Forwarded Message From: jordan@heuristicrat.com (Jordan Hayes) Subject: Re: Virtual top-level home pages on the same machine [ by popular demand; I did this a few months ago (a Sparc I have here has 10 addresses! Thanks, Tim!). I have since seen a patch from some luser on the net that's hundreds of lines long. I couldn't even tell if it did what I thought it did. Anyway, here's what I did. I did something similar to inetd so that you can have multiple inetd's running in the same way. Fun city. ] There is a configuration item in the CERN httpd called "hostname" but it appears not to be used for anything. So I use that. If you have the CERN 1.3 source, the server lives in Daemon/Implementation. - - In HTConfig.h (around line 45), I added a struct in_addr to the struct _HTServerConfig - - In HTConfig.c (around line 1100) I initialize sc.addr.s_addr to INADDR_ANY - - there's a big pile of code that parses the config file. When you get to the "hostname" directive (around line 1755), I added: struct hostent *hp; if ((hp = gethostbyname(vec[1])) != (struct hostent *)NULL) bcopy((char *)hp->h_addr, (char *)&sc.addr.s_addr, sizeof(sc.addr.s_addr)); - - In HTDaemon.c (around line 1324) I changed the line sin->sin_addr.s_addr = INADDR_ANY; /* Default: any address */ to sin->sin_addr.s_addr = sc.addr.s_addr; - ----- If the "hostname" directive doesn't exist, this is a no-op; the bind() call just listens on all interfaces. If it does exist, and we can resolve it (make sure there's an A record for the particular interface that you want to listen on), it gets used instead. Use the -r argument to httpd to have separate config files. Actual diffs (I lied: I added 7 lines and changed one): =================================================================== RCS file: RCS/HTConfig.c,v retrieving revision 1.1 diff -r1.1 HTConfig.c 1081a1082 > struct hostent *hp; 1103a1105,1106 > sc.addr.s_addr = INADDR_ANY; > 1755a1759,1761 > if ((hp = gethostbyname(vec[1])) != (struct hostent *)NULL) > bcopy((char *)hp->h_addr, (char *)&sc.addr.s_addr, > sizeof(sc.addr.s_addr)); =================================================================== RCS file: RCS/HTConfig.h,v retrieving revision 1.1 diff -r1.1 HTConfig.h 45a46 > struct in_addr addr; /* virtual hosts */ =================================================================== RCS file: RCS/HTDaemon.c,v retrieving revision 1.1 diff -r1.1 HTDaemon.c 1324c1324 < sin->sin_addr.s_addr = INADDR_ANY; /* Default: any address */ - --- > sin->sin_addr.s_addr = sc.addr.s_addr; ------- End of Forwarded Message