Awesome! I used to think (well, I still do) that getting a barebones service up and running using the system APIs at the lowest level like this is so satisfying. It's sort of magical, really. And to see it serve real traffic! I'm kind of surprised that the vanilla poll() can put up numbers like you were seeing, but I guess it's been a while since I've had to do anything event related/benchmark at that level. I love t…
Show HN: Hosting my website using my C web server
151–160 of 160 posts
Re: Show HN: Hosting my website using my C web server
#152Earlier quoted context omitted.
I run many server programs on my homelab. Each is running on a different port, but I want them all accessible publicly from different URLs and I only want to expose port 443 to the internet. I also want to have TLS autorefresh for each domain. I need a reverse proxy for the former and caddy does both. If you’re running a single server and that server does TLS termination then you don’t really need a reverse proxy.
e.g. Virtual hosting as we called it in the Apache days
Re: Show HN: Hosting my website using my C web server
#153Earlier quoted context omitted.
does that mean recompile every time them HTML is changed? No thanks :)
A nice intermediate I use is baking the paths into the source code, so that I only recompile when I add files, but I can hot-swap contents without even restarting the server. Although if you start caching contents in memory (which is faster) you would have to at least kill the server and restart it. Or signal a reload.
Re: Show HN: Hosting my website using my C web server
#154> No Transfer-Encoding: Chunked (responds with 411 Length Required, prompting the client to resend with Content-Length I've always wanted to undertake a project similar to this but chunked encoding has always been the thing that put me off the idea... I never even though about just not supporting that :) I've written many http/1.1 servers in the past but only for internal stuff that I also controlled the clients. Gue…
It does mean you have to read the client's headers to see if it was requested, though.
Re: Show HN: Hosting my website using my C web server
#155Earlier quoted context omitted.
For a blog? If you don't put anything important on the server itself I can't imagine a hacker could do much. Maybe put a nasty image on your front page, or put their Bitcoin address pretending it's the place to send donations, but it would take a lot of time and effort to remain hidden for hardly any gain.
or take over your server?
And possibly serve attacker-controller content to other users.
Re: Show HN: Hosting my website using my C web server
#156Earlier quoted context omitted.
I run many server programs on my homelab. Each is running on a different port, but I want them all accessible publicly from different URLs and I only want to expose port 443 to the internet. I also want to have TLS autorefresh for each domain. I need a reverse proxy for the former and caddy does both. If you’re running a single server and that server does TLS termination then you don’t really need a reverse proxy.
Every page off of my (static HTML file!) home page[1] is actually a distinct microservice sitting behind a reverse proxy. I can throw some new experiment together, built it with whatever tooling I want, give it a port number, and let nginx route to it. It removes a lot of friction from "I wonder if making this service is a good idea?" and because I am self hosting I am not tying myself down to any of the "all in one"…
Re: Show HN: Hosting my website using my C web server
#157Nginx is C web server.
So is Apache and OpenBSD httpd and probably too many others to name. Node.js is written in C/C++ as is Litespeed, probably Cloudflare Server as well. Microsoft IIS is written in C++. So that accounts for about the top 5 ...
Re: Show HN: Hosting my website using my C web server
#158Re: Show HN: Hosting my website using my C web server
#159I used smallhttpserv - a program that weighs a couple of dozen kilobytes and works even in early Windows
surprisingly, it still works
Re: Show HN: Hosting my website using my C web server
#160> No Transfer-Encoding: Chunked (responds with 411 Length Required, prompting the client to resend with Content-Length I've always wanted to undertake a project similar to this but chunked encoding has always been the thing that put me off the idea... I never even though about just not supporting that :) I've written many http/1.1 servers in the past but only for internal stuff that I also controlled the clients. Gue…
Chunked encoding is pretty easy no? Just write the full size and \r\n, you can send as one chunk. It does mean you have to read the client's headers to see if it was requested, though.