TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Acme Thttpd

80 pointsby assttoasstmgralmost 3 years ago

7 comments

fanf2almost 3 years ago
I worked at Demon Internet in the late 1990s, and our “homepages” service ran on thttpd. My colleagues had hacked an earlier version to support mass virtual hosting - there were tens of thousands of homepages web sites at a time when that was a lot.<p>On the front end we had a few cacheing reverse proxies running Squid on FreeBSD, like an early CDN (we had nodes in London and New York). The FreeBSD kernel was hacked to support configuring IP addresses by the CIDR block instead of individually. When Homepages was set up, the HTTP Host: header was not yet well supported, so it needed an IP address per web site. The Squid boxes had 96k addresses each (a &#x2F;16 and two &#x2F;18s) and the network was configured to spread the load across them.<p>Squid was modified to translate the server IP address into a Host header as necessary, so the back end did not need many IP addresses. There was one box running thttpd, one box running an FTP server for uploads, and a NetApp NFS storage server. There were hacks in thttpd to shard the web site names across multiple directories to avoid performance problems with very large directories.<p>We made some effort to get the modifications upstream, tho thttpd had diverged a lot by the time we sent our code to Jef. But, IIRC thttpd’s vhost setup has some resemblance to the way Demon did things. (This is also why Apache httpd mod_vhost_alias is so weird.) And these days, firewalls can be configured to do the CIDR IP address trick, so there is no need for kernel hacking.<p>(edited to add) Here&#x27;s an old blog post on the topic, with the links I left out of this comment <a href="https:&#x2F;&#x2F;dotat.at&#x2F;@&#x2F;2012-09-25-large-scale-ip-based-virtual-hosting.html" rel="nofollow">https:&#x2F;&#x2F;dotat.at&#x2F;@&#x2F;2012-09-25-large-scale-ip-based-virtual-h...</a>
protomythalmost 3 years ago
Still one of the funniest stories about the clueless <a href="https:&#x2F;&#x2F;www.acme.com&#x2F;software&#x2F;thttpd&#x2F;repo.html" rel="nofollow">https:&#x2F;&#x2F;www.acme.com&#x2F;software&#x2F;thttpd&#x2F;repo.html</a>
评论 #31662447 未加载
评论 #31662411 未加载
评论 #31663394 未加载
评论 #31667133 未加载
kstrauseralmost 3 years ago
See also: Tuttle, Oklahoma vs CentOS. <a href="https:&#x2F;&#x2F;www.theregister.com&#x2F;2006&#x2F;03&#x2F;24&#x2F;tuttle_centos&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.theregister.com&#x2F;2006&#x2F;03&#x2F;24&#x2F;tuttle_centos&#x2F;</a>
mro_namealmost 3 years ago
I love such focused, cooperative and mature tools. They do one thing well, play nicely and keep their promises.<p>however, using lighttpd due to https.
评论 #31667712 未加载
1vuio0pswjnm7almost 3 years ago
To test, chdir to directory with files to be served before running<p><pre><code> #ifndef IDX #define IDX 1 #endif #if IDX==1 &#x2F;&#x2F; final #include&#x2F;* micro HTTP server *&#x2F;&lt;stdio.h&gt; #include&#x2F;* usage: .&#x2F;http [port] *&#x2F;&lt;stdlib.h&gt; #include&#x2F;* *&#x2F;&lt;string.h&gt; #include&#x2F;* the default port is 8080, files are *&#x2F;&lt;unistd.h&gt; #include&#x2F;* read from the current directory *&#x2F;&lt;netdb.h&gt; int main(int n,char** V){int t=SOCK_STREAM, N=SO_REUSEADDR,i=1,c= htons(n &gt;1?atoi (V[1]): 404*20) ;struct sockaddr_in s ={000}; void*f= &amp;s;char *m,b[1036];s.sin_port =c;for( N=!((t= socket( s.sin_family=AF_INET, #define http(c) setsock ##opt(\ t,SOL_S ##OCKET ,N,&amp;i,c (i)),bi ##nd(t,f,c(s))&lt;0)|| t,0))&lt;0 ||(http (sizeof )listen (t,5))&lt;&lt;10;N&amp;&amp;(0)&lt;=(c =accept(t,0,0));close (c)){b[ n=recv( c,b,N,0),0&gt;n?0:n]=0;n =!memcmp(b,&quot;GET &#x2F;&quot;,5) &lt;&lt;6;for (i=4;n^ &#x27;?&#x27;&amp;&amp;n&lt; 127&amp;&amp;n&gt; 32;){n=b[++i];}strcpy (b+i,b[ f=0,i-1 ]==&#x27;&#x2F;&#x27;? &quot;index&quot; &quot;.html&quot; :&quot;&quot;);m= n?puts( b+5),b[ 03]=&#x27;.&#x27; ,strstr (b,&quot;&#x2F;.&quot; )||0==( f=fopen (&amp;b[3], &quot;rb&quot;))?&quot;404 Not Foun&quot; &quot;d&quot;:&quot;2&quot; &quot;00 OK&quot; :&quot;501 &quot; &quot;Not Implemented&quot;;for ((send) ((c),b, sprintf (b,&quot;HTTP&#x2F;1.1 %s\r\n&quot; &quot;\r\n%&quot; &quot;s&quot;,m,f ?&quot;&quot;:m), 0);f&amp;&amp;! ((send) (c,b+0, fread(b ,1,N,f) ,0)-N&amp;&amp; (fclose (f),404 )););}} #elif IDX==2 &#x2F;&#x2F; almost readable #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #ifdef _WIN32 &#x2F;* needs linking with Ws2_32 *&#x2F; #include &lt;winsock2.h&gt; #define close closesocket #define strstr(a,b)strstr(a,b)||strchr(a,&#x27;:&#x27;)||strchr(a,&#x27;\\&#x27;) #define struct WSADATA w={0};WSAStartup(514,&amp;w);struct #else #include &lt;unistd.h&gt; #include &lt;netdb.h&gt; #endif int main(int N,char**V){ int i=1,t,c,n;struct sockaddr_in s={0}; char b[1036];const char*m;void*f; s.sin_port=htons(N&gt;1?atoi(V[1]):8080); for(N=(t=socket(s.sin_family=AF_INET,SOCK_STREAM,0))&lt;0|| (setsockopt(t,SOL_SOCKET,SO_REUSEADDR,f=&amp;i,sizeof(i)), bind(t,f=&amp;s,sizeof(s)))||listen(t,5)?0:1024; N&amp;&amp;(c=accept(t,f=0,0))&gt;=0;close(c)){ b[0&gt;(n=recv(c,b,N,0))?0:n]=0; for(n=!memcmp(b,&quot;GET &#x2F;&quot;,i=5)&lt;&lt;6;&#x27;?&#x27;^n&amp;&amp;32&lt;n&amp;&amp;n&lt;127;)n=b[i++]; m=n?strcpy(b+i-1,b[i-2]-&#x27;&#x2F;&#x27;?&quot;&quot;:&quot;index.html&quot;), puts(b+5),b[3]=&#x27;.&#x27;,strstr(b,&quot;&#x2F;.&quot;)||!(f=fopen(b+3,&quot;rb&quot;))? &quot;404 Not Found&quot;:&quot;200 OK&quot;:&quot;501 Not Implemented&quot;; for(send(c,b,sprintf(b,&quot;HTTP&#x2F;1.1 %s\r\n\r\n%s&quot;,m,f?&quot;&quot;:m),0); f&amp;&amp;!(send(c,b,fread(b,1,N,f),0)-N&amp;&amp;fclose(f)|N);); } } #endif </code></pre> <a href="https:&#x2F;&#x2F;github.com&#x2F;ilyakurdyukov&#x2F;ioccc&#x2F;blob&#x2F;main&#x2F;practice&#x2F;2021.07-http&#x2F;prog.c" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ilyakurdyukov&#x2F;ioccc&#x2F;blob&#x2F;main&#x2F;practice&#x2F;20...</a>
elpescadoalmost 3 years ago
&gt; In typical use it&#x27;s about as fast as the best full-featured servers (Apache, NCSA, Netscape).<p>That&#x27;s names i haven&#x27;t heard in a long time!
JayGuerettealmost 3 years ago
For static content and cgi-bin, busybox is much faster.
评论 #31663749 未加载