Out of curiosity, are there alternatives to this that are already well established or distributed? For example, something you'd get in debian linux?
static-server: an HTTP server in Go for static content
51–60 of 67 posts
Re: static-server: an HTTP server in Go for static content
#52This is cool - I didn't know you could have Go one-liners that look like this: go run github.com/eliben/static-server@latest I had to upgrade to Go 1.21 for this to work - I was previously on Go 1.20. "brew upgrade go" worked for me. Looks like almost the entire implementation is here, it's mostly CLI option parsing logic: https://github.com/eliben/static-server/blob/main/internal/s...
$ go run .
go: errors parsing go.mod:
.../static-server/go.mod:3: invalid go version '1.21.0': must match format 1.23
Eli, you might consider changing that to "go 1.20" so it works on Go 1.20 (and older, actually -- it's the 1.2.3 format that is getting in the way on Go pre-1.21).Re: static-server: an HTTP server in Go for static content
#53Earlier quoted context omitted.
Caddy 1 was created because I needed a quick and easy web server for a lot of my projects. Caddy 2 was created when I got serious about it, and we had governments and enterprises starting to rely on the project. Now we exist because we advocate for (and deliver!) HTTPS on every site, memory safety, dynamic configuration, extensibility, and many more features valuable in a modern web server. Hope that helps :)
Thank you for the response. It looks interesting. >I needed a quick and easy web server I am trying to reason with what I know, but wouldn't something like "python -m http.server 9000" suffice? Or nginx? These are battle tested and python is there on most platforms. Or is there more depth to this specific web server that others don't have?
And Caddy is very well battle-tested too, btw. ;)
Re: static-server: an HTTP server in Go for static content
#54Earlier quoted context omitted.
I think nginx does that too; if you send it a hup signal, it will reload the config.
Indeed, many programs interpret a kill -HUP signal as a "re-read config" command.
(One reason we don't use signals in Caddy 2. So uncivilized.)
Re: static-server: an HTTP server in Go for static content
#55These are fun to make. I've done it several times. :) That is why I wrote Caddy: $ caddy file-server It does templates, TLS, and other production things really easily from the command line too, including automatically getting certificates: $ caddy file-server --domain example.com Done! I think projects like static-server are wonderful learning examples of how to get Useful Things done in Go.
Re: static-server: an HTTP server in Go for static content
#56These are fun to make. I've done it several times. :) That is why I wrote Caddy: $ caddy file-server It does templates, TLS, and other production things really easily from the command line too, including automatically getting certificates: $ caddy file-server --domain example.com Done! I think projects like static-server are wonderful learning examples of how to get Useful Things done in Go.
Thank you for Caddy! Going from a complex nginx setup to the delight that's the Caddyfile was a breeze. And a special call-out to your dedication to providing amazing documentation. Caddy is what all projects should aspire to be.
Anyway I decided to try Caddy to quickly get up and running and had a good setup in minutes including certificates for multiple domains. Even added wildcard certificates which I never figured out with Lets Encrypt, just because I could.
Thanks for this amazing software :-)
Re: static-server: an HTTP server in Go for static content
#57Out of curiosity, are there alternatives to this that are already well established or distributed? For example, something you'd get in debian linux?
Re: static-server: an HTTP server in Go for static content
#58https://github.com/philippgille/serve
One difference is that it can create a TLS cert for you, instead of having to supply one via CLI arg.
I don't recommend using it in its current form though due to its (the compiled binaries') Go version being outdated.
Re: static-server: an HTTP server in Go for static content
#59Re: static-server: an HTTP server in Go for static content
#60Out of curiosity, are there alternatives to this that are already well established or distributed? For example, something you'd get in debian linux?
apache? nginx? Serving static content off the file system is braindead simple.