Live data from Hacker News

Show HN: Hosting my website using my C web server

github.com

11–20 of 160 posts

Re: Show HN: Hosting my website using my C web server

#11

How about embedding the contents of the HTML files so that no access to the filesystem is required? That would make it not only faster but also safer.

I recommend linking a romfs image into the program. It's a simple format and provides an easy way to manage a collection of resources.

Re: Show HN: Hosting my website using my C web server

#12
post #4

Nice. I've done this in the past. But I feel like attempting to make a file serving http server is like adding preservants and high fructose corn syrup to home made baked goods. You have the opportunity to really make something custom and of high quality, hard code the paths of your files and avoid a whole class of vulnerabilities for example. Configuration files? That makes sense when programmer and sysadmin are dis…

Not sure if serious…

Not the only time it’s been brought up in this thread: https://news.ycombinator.com/item?id=41643198

I’m waiting for someone to chime in and explain why that would be a bad idea cause I can’t think of it from a security perspective.

Re: Show HN: Hosting my website using my C web server

#14
post #12

Earlier quoted context omitted.

Not sure if serious…

Not the only time it’s been brought up in this thread: https://news.ycombinator.com/item?id=41643198 I’m waiting for someone to chime in and explain why that would be a bad idea cause I can’t think of it from a security perspective.

Once at a certain level of complexity, e.g. having several hundred/thousand resources, then you start automating your hardcoded paths, and then you still can get bitten.

vs just putting things in a subfolder of your repo or whatever and having the default handling not accept `..` path components

Re: Show HN: Hosting my website using my C web server

#15

Earlier quoted context omitted.

For fun, sure. Small mistake can be big security nightmare

1000 lines are easier to secure than 5 million lines

“You can write software that has no obvious bugs or you can write software that obviously has no bugs.”

I think that was ewd?

Re: Show HN: Hosting my website using my C web server

#16

Only 3.4k of C code for a full http and https server? I honestly thought you would need a lot more for it to be fully compliant with the spec.

Http/1.1 is dead simple if you ignore most of the spec. If you only take get requests and set content-length on response you will be good for 99% of user agents. It’s not much more code to handle the transfer-encoding and byte-range headers. HTTPS is just http over a tls socket which is the level of abstraction you should have if you don’t roll your own crypto.

It’s fun and not that bad really.

Re: Show HN: Hosting my website using my C web server

#18
post #4

Nice. I've done this in the past. But I feel like attempting to make a file serving http server is like adding preservants and high fructose corn syrup to home made baked goods. You have the opportunity to really make something custom and of high quality, hard code the paths of your files and avoid a whole class of vulnerabilities for example. Configuration files? That makes sense when programmer and sysadmin are dis…

I think you'll like dwm and other suckless tools. They have configuration as code and require a recompile after a configuration change.

Re: Show HN: Hosting my website using my C web server

#20

Only 3.4k of C code for a full http and https server? I honestly thought you would need a lot more for it to be fully compliant with the spec.

Http/1.1 is dead simple if you ignore most of the spec. If you only take get requests and set content-length on response you will be good for 99% of user agents. It’s not much more code to handle the transfer-encoding and byte-range headers. HTTPS is just http over a tls socket which is the level of abstraction you should have if you don’t roll your own crypto. It’s fun and not that bad really.

Yeah I’ve done this for embedded devices. A website can be presented with nothing more than a raw socket and sending back a text string of http headers and html in a single text string when people connect to it.

Hell if you’re really lazy you can forgo responding with the http headers and just socket.write(“hello world”) as the response and all the major browsers will render “hello world” to the user. Properly formatted http headers are just a text string extra and the html is just text. There’s not much to it.

Post reply on HN