Httpx takes over the front-line position of binding and listening on the public address & port of your virtual webhosting server. In this role, httpx snoops incoming requests looking for the now ubiquitous HTTP/1.1 Host request header line. Once the Host line is found by httpx for a given request, httpx performs a simple SELECT on a MySQL database with the found Host value. For valid hosts (those matching rows in the database), a Path column is returned and used as a path into the local filesystem. The purpose of this path is to provide an address for reaching the appropriate web server processes responsible for the domain specified in the Host request header. The file residing at this path is a named UNIX domain socket, with a real httpd process instance waiting at the other side on behalf of the respective domain ready to serve.
Note that httpx is not a proxy, httpx employs the inter-process descriptor passing capabilities of UNIX to hand off the socket to the appropriate process by using a combination of somewhat obscure and scarcely used features. Namely, the MSG_PEEK flag for recv() is utilized for accessing the requests socket buffer contents without actually removing anything from the socket buffer. The SO_RCVLOWAT socket option is utilized to inform the socket layer to block as we accumulate more data in the sockets receive buffer when we have yet to find the Host request header line in the previous recv() calls with the MSG_PEEK flag. Together, when implemented properly, these features allow us to efficiently snoop on the request without leaving any evidence for the destination httpd process to trip on.
By using these features httpx introduces minimal overhead, and allows us to continue using all the popular web server software - even more freely than before, since you don't need to be concerned about things like mod_perl or mod_php security issues or instabilities effecting the shared process space of your entire vhosts pool. Every domain can have it's own minimal specific and simply configured instance of Apache, while sharing a single IP:port. Every domain can even run a completely different web server software if desired.
All that is required is a minor patch to the web server software of interest to enable accepting sockets over a UNIX domain socket stream, which is a pretty trivial change that deviates only slightly from the already present AF_INET bind, listen, and accept arrangement. Once the software has received the passed descriptor, it's the same old tcp socket as it worked with before.
The Shttp ServerKit module as of version 0.0.10 has been modified to support the required UNIX domain socket descriptor passing if you would like to experiment with httpx immediately. Or you can try your hand at patching one of the web servers I've created a patch for.
Looks like these incompatibilities will be fixed in a future Linux version:
httpx may be insane but it presents a practical and compelling argument
Commits 518a09ef11f8454f4676125d47c3e775b300c6a5 and c7004482e8dcb7c3c72666395cfa98a216a4fb70 by David Miller made it into Linux-2.6.28 which solve the bad SO_RCVLOWAT sockopt and MSG_PEEK recv() flag interaction, as well as the problem with poll() not respecting SO_RCVLOWAT.
On kernels >= 2.6.28 remove the "#define BROKEN_LINUX_RCVLOWAT" from httpx.c before compiling.
You will probably want to use the included ServerKit personality as a starting point, found in the source archive as a directory named personality. Within the personality you will find a c11n file, a modules subdirectory, and a svsdir subdirectory.
The c11n file is a ServerKit configuration file, you will need to at least modify the database settings so ServerKit can successfully communicate with your database system.
You are responsible for creating a database and table compatible with httpx, please see the included INSTALL file for information on the expected schema.
|min_sessions||integer||Minimum number of sessions to allocate.|
|max_sessions||integer||Maximum number of sessions to allocate.|
|min_threads||integer||Minimum number of worker threads to create.|
|max_threads||integer||Maximum number of worker threads to create.|
|database||string||Identifier of database connection pool instance to use, see ServerKit configuration for assistance with database connection pool configuration.|
|backlog||integer||Size of kernel-level connection backlog, passed to listen() as-is|
|listen_address||string||Address to listen on|
|listen_port||integer||Port to bind to|
|default_path||string||UNIX domain socket to pass sockets having requests with no Host: header|
You can query the module for its supported configuration options by simply running it like a normal executable program. This is the preferred method of keeping informed on what configuration values are supported and what the defaults are.
Here is some sample output of running the module:
swivel@volatile:~/src/httpx-0.0.1$ ./httpx.so ServerKit bundled module inspector - Summary - Name: httpx Description: HTTP/1.1 host-specific httpd switch Module version: 0.0.1 ServerKit build environment version: 2.1.0 Authors: Vito Caputo <vcap***NOSPAM***ru.com> - Supported configuration options & defaults - listen_port = 80 listen_address = "0.0.0.0" backlog = 16 max_sessions = 65536 min_sessions = 64 min_threads = 4 max_threads = 100 # database = ""
|Release date||Tar.gz||MD5 checksum|
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
If you would like to contribute to this project monetarily, feel free to donate via the paypal button below.