379 points · by thunderbong · 3y ago · 283 comments
Can we give a huge round of applause to Maxim Dounin for community support and technical excellence?
Maxim and team are answering the deepest of technical questions patiently, to the point.
Every time I read into those threads I am impressed by Maxim. By his dry communication style, his precision, and his patience. It's inspiring.
When you get his reply (which is likely to be the case), you typically get the problem you presented described in his words: with precise language/terms. Very likely he provides a solution. Or a precise quote of reference docs or spec describing why something doesn't work, conceptually. Or a patch (he often replies with "here's a patch that should work", showing a clean diff).
So: https://mailman.nginx.org/pipermail/nginx/ -- highly recommended if you want to learn more about HTTP and web servers in general.
By the way: for forcing DNS re-resolution (mentioned in this thread here) in the open source version by the way there is a weird but extremely powerful workaround (which really works, we have used it in DC/OS successfully over years), also see https://github.com/dcos/dcos/tree/master/packages/adminroute....
It was of course Maxim who described this little trick in the mailing list in 2011 :-) https://forum.nginx.org/read.php?2,215830,215832#msg-215832
It's still highly relevant in 2023 for controlled dynamic service discovery with nginx.
I recently made the mistake/challenge to use nginx as a SSL reverse proxy for a bunch of non SSL services running in docker containers .
To my dismay there is no decent documentation for what I thought would be a common usage case - namely docker for everything including nginx.
* SSL was easy enough - I have a wild card certificate and nginx does have good docs on setting it up
* Docker networking was a bit of pain - but I solved it by making a separate network.
* proxy_pass is where I got really bogged down - I got to rewrite location /api and serve it at the internal network + port.
location /api/ {
rewrite ^/api(.*)$ $1 break;
# proxy_pass http://172.19.0.3; # also works
proxy_pass http://172.19.0.1:9090;
# most likely something else is needed for fix relative paths
}
So now I have the problem that proxy works for mysite/api/index.html but not for any relative paths ie static/css/style.css is not loading (but docker exec -it mycontainer curl does work)Maybe it is Google's fault but it seems near impossible to find a good AUTHORATIVE reference on setting up reverse proxy server with nginx.
But as the saying went with apache, if you have a routing problem, you can fix it with mod_rewrite - now you have two problems!
You might want to (re)read:
https://nginx.org/en/docs/http/request_processing.html
and skim:
https://nginx.org/en/docs/http/load_balancing.html
And (re)read:
https://nginx.org/en/docs/http/ngx_http_proxy_module.html#pr...
It seems dubious that you need any rewriting for your setup.
You might need a handful of server blocks (vhosts) with either proxy_pass or a few locations with proxy_pass?
So using a subdomain should solve routing issues - api.myproject.myorg.org instead of myproject.myorg.org/api ?
Two issues - my wildcard cert is *.myorg.org so not 100% it would cover subdomains of subdomains.
Second issue - you'd need to set up DNS for subdomain of subdomain, would you not?
Sadly DNS setup would require opening an uncertain to complete support ticket in myorg...
My employer (Wikimedia, which is a non-profit) has been running all our server infra on pure open source for many years, for very principled reasons. We even publish all of our internal infrastructure config in public git repos as well. We're an open-source-only shop that's doing very non-hobby work. We have thousands of servers, we run our own CDN on multiple continents, we have somewhere around a billion unique users per month, and our average global rate of inbound HTTP requests is around 135K/second.
However, it keeps getting harder to stick to our open source principles every year as more projects shift towards open-core models with this kind of "Anyone who needs feature X is surely a big corporation making billions who doesn't mind running closed source software" type of thinking. It's not just bad for us, it's bad for the whole larger open source and Internet ecosystems if all the important bits for running at scale are locked up and hidden away in closed-source software.
Accepting these "sprinkles on top" licenses is highly foolish. I do hope that the true free and open source licensed software prevails in the server space. As many as possible must continue to hold out and push forward with new better and better scalable fully open source software.
Curious how deep does it go? Do you only use firmware in server which has open source code. Do you require all drivers to be open source?
> It should be possible to run large-scale important things on pure open source.
It is definitely possible. With enough developer time, you could create copy of any software. Every paid or open core software runs on the philosophy that it is cheaper to pay them rather than to build them.
Which brings to the core issue, developer time is not free or cheap. The fact is that software quality and reliability is dependent on the money that the software has means paid software quality in general should be higher. While wikimedia could get enough money through donation, no one donates to open source projects that could be counted in full time developer salary, likely not even wikipedia(correct me if wrong).
It has been built by extending Nginx with an OpenResty-based DNS resolver instead. You could even extract it away from Kong itself and use it standalone.
It took me almost exactly 3 minutes start to finish with letsencypt. Where 'start' was "I should stop putting that off" and typing "letsencrypt.com" into a browser, and 'finish' was nginx serving up https:// on all my domains. I'm genuinely curious what nginx could possibly do to improve the situation there.
You don't have to mess with having a .well-known always accessible on each domain, for example. Caddy does it for you and only when it's needed.
Nginx has a profit from big business that would require coordination to avoid multiple certificates. For comparison, it is worth noting that to ensure such coordination, Traefik requires an Enterprise plan and a separate agent. Such a business also often has mechanisms for storing certificates, so they do not necessarily want to integrate it into Nginx.
Well, for what it's worth, certbot is still pretty good: https://certbot.eff.org/
That said, with servers like Caddy supporting automatic TLS and even Apache httpd having built in support now with mod_md, Nginx feels more like an outlier for not supporting ACME out of the box: https://httpd.apache.org/docs/2.4/mod/mod_md.html
For my personal sites I actually use Apache because it's pretty good and has lots of modules (including OpenID Connect support for Keycloak etc.), but Nginx has always been really easy to install and setup, especially for serving static files (e.g. built front end apps) or being a basic reverse proxy.
Here's a bit more about how I use Apache: https://blog.kronis.dev/tutorials/how-and-why-to-use-apache-...
And a little bit about some of the occasional warts of Nginx: https://blog.kronis.dev/everything%20is%20broken/nginx-confi... (though otherwise it's fine)
That said using HTTP-01 instead of DNS-01 across multiple nodes with the same hostname is needlessly complex in most cases and DNS-01 doesn't always have the best support in web servers (Apache in particular is just like: "Yeah, we can run whatever script you want, but the contents and integrating with your DNS server is up to you").
Also, there's massive advantages to having TLS issuance built into the webserver, such as proper OCSP stapling, having an active process to trigger renewals as soon as a revocation happens (hearing about it via OCSP), solving the ACME TLS-ALPN challenge without extra steps, and unique features like On-Demand TLS that many SaaS companies are relying on to provide a custom domains feature to their customers. None of those things are possible unless it's tightly integrated in the webserver.
Vs just actually selling the software and having it work flawlessly with minimal work.
Pay for the features you want. You will be better off for it. Expecting every company to follow the RedHat model is unsustainable.
If it's actually gated, not enough people care enough to get together and make and maintain a better one themselves.
Literally, at work (a startup), we use Traefik (which is horrible imho) instead of nginx (which I've used literally everywhere else) because the devs who originally started this project had never used it on a personal project.
So the issue isn't paying for it, it is about making it useful enough for personal projects that people use it for personal projects that it then gets used on professional projects. Right now, it is barely useful for personal projects unless you know what you're doing.
Do I personally need DNS SRV support? No, I have a templated Nomad config that will re-render and reload the nginx config if the consul upstreams change. Setting this up though is definitely a bigger hurdle than just specifying a Consul service as an upstream.
We do pay them, for a bunch of boxes. But I can't afford to run their plus version in front of every microservice. Or even in front of our entry point server. That's 5 times as many machines, plus staged versions of the app, plus other services running on the same boxes.
If you're running anything that is not multithreaded, you're running a reverse proxy in front of it. And even then you can still improve server availability by running a reverse proxy.
I really wish companies would come up with SMB pricing to help us side project hackers out so we could grow into paying for the bigger plans. Also, I understand why they don't. SMB support is a huge PITA.
While one can talk about corporate contributions and basically ownership of some open source projects (the F5/Nginx case included), I also think that the funding is a big challenge for many projects out there.
Now, this is from 2019, but I found the article "Software below the poverty line" to be a useful if a bit grim look at the way things are: https://staltz.com/software-below-the-poverty-line.html
It will be interesting to see how their native implementation compares.
Implementing QUIC seems no fun and there are almost no implementations. Almost everybody claiming HTTP/3 support uses Quiche under the hood for QUIC (besides some outliers and AWS who are one of the very small group of orgs who have their own QUIC lib). I was under the impression NGINX kept building on the current foundations with Quiche.
Instead, we ship with our own debian repo, hosting graciously provided by CloudSmith https://caddyserver.com/docs/install#debian-ubuntu-raspbian. This is packaged via CD with GitHub Actions, and you can verify the authenticity of the build since it's signed by Matt Holt's GPG key.
For RHEL, it's in COPR, and that's the best you'll ever get for similar reasons https://copr.fedorainfracloud.org/coprs/g/caddy/caddy/
Debian 12 (bookworm) will have it: https://packages.debian.org/bookworm/caddy
Despite v2 supporting a very similar config file, the documentation doesn't emphasise that and tries to steer you towards its API, confusing JSON config syntax etc.
It's still a very good web server for very few lines of config, but I don't relish trying to learn something new from its docs like I used to.
I disagree. The docs don't do that. What you're probably talking about is the Getting Started guide https://caddyserver.com/docs/getting-started, which is a tour of how Caddy works, so it first shows you the "bare-metal" look at how it works, then it introduces the Caddyfile which allows you to simplify your user experience.
There's even a comparison table between the two https://caddyserver.com/docs/getting-started#json-vs-caddyfi... which explains when you'd want to use JSON (i.e. if you want programmable, API-based usage) or Caddyfile (i.e. for quick-and-simple hand-written config, 95% of users choose this).
I recommend starting from https://caddyserver.com/docs/caddyfile-tutorial or https://caddyserver.com/docs/caddyfile/concepts to get an idea of how the Caddyfile works.
> The Caddyfile seems easier than JSON, but should you always use it? There are pros and cons to each approach. The answer depends on your requirements and use case.
Followed by a table comparing the json and caddyfile approaches. What's the confusion?
I agree with this, v1 was an excellent user experience, I actually ran it on my servers for way too long. There was also the Wedge fork which might have helped with the EOL but sadly it didn't go anywhere: https://github.com/WedgeServer/wedge
> Despite v2 supporting a very similar config file, the documentation doesn't emphasise that and tries to steer you towards its API, confusing JSON config syntax etc.
Others responded to this a bit more, but while I agree that different config types are a confusing experience, at the same time I appreciate that they support something like that in the first place. I might not use it often, but it's nice that you can.
It’s too bad, I only moved away from caddy because of weird disconnection issues when reverse proxying certain apps.
https://dropbox.tech/frontend/investigating-the-impact-of-ht...
(Discussed at https://news.ycombinator.com/item?id=36027702.)
For the majority of our global users, HTTP3 reduced network latencies by 5-15ms (or 5%). While this is an improvement, these wins would appear negligible to the average user. At p90, however, HTTP3 demonstrated massive improvements, with a latency reduction of 48ms (or 13%)—and at p95, a reduction of 146ms (21%). This could be explained by the fact that HTTP3 is better at handling packet drops in parallel connections by eliminating head-of-line blocking; because packet drops are more likely to occur in networks with suboptimal connection quality, the benefits of HTTP3 are more visible at the higher percentiles.Of course it's true that QUIC is a complexity monster. OTOH HTTP/3 is actually quite simple when you have the QUIC layer implemented. A simple HTTP/3 server is no more than this:
https://github.com/aiortc/aioquic/blob/main/examples/http3_s...
People have definitely gotten more impatient over the years.
There was quite a bit of pushback on this in the IETF from financial institutions that think they have mandatory obligations to spy on their employees.
Here is a relevant HN discussion thread from 2016 about TLS 1.3, most of which applies to HTTP/3: https://news.ycombinator.com/item?id=12641880
I assume Google and co. will fix this if it ever starts to seriously benefit platforms like KiwiFarms, which in the last year was being blocked by CenturyLink, a major US ISP. I also predict these QUICfixes will be met with broad enthusiasm by HNers.
plus, in real-world use cases it's probably a perf loss running TLS like this fwiw.
Are there any prove points for this claim besides this shout-out?
QUIC is more like a modern TCP. What you do with such a protocol is unrelated to the protocol as such. You can open secure connections and stream data with it. That's all. Everything else is on the application side.
> Something like dns-over-http/3 is, allegedly, referred to internally at Google as the anti-Pi-hole
This claim sounds like anti QUIC FUD.
Nothing can stop you from using a Pi-hole like device as your primary DNS resolver!
(OK, I admit Google could try to hard-code their DNS servers in Chrome. But I'm very unsure they would make it through the following shit storm in one piece.)
More relevantly, there's no reason they couldn't do the same before HTTP/3. Even with DNS traffic hijacking, they could just as well do DNS-over-TLS. Infiltrating advertising-related DNS is completely orthogonal to HTTP/3; agreed that the gp comment is FUD.
What? What is your source on this? How does the protocol stop you from using e.g. uBlock to filter the domains at the application level?
It's the main reason why I'm thinking about migrating everything to Caddy.
In this particular case, the ngx_http_api module offers way more monitoring options but is gated behind nginx Plus.
Only "serious" companies need that (as a hobby project maintainer you probably don't need it)... and if you really want to make sure you don't give them a cent, you can build your own monitoring on top of nginx easily enough.
But if Caddy can serve metrics which I can then collect with for example Grafana, that’s very interesting!
But caveat: we don't have maintainers who understand metrics currently, so it's nowhere near as good as we'd hope it to be. Help wanted!
That said, I've been running it since the early days, on super heavy production loads and never felt the need to have some more "decent" metrics out of it. I assume you're referring to real time metrics here.
Most if not everything can be gathered from the logs, which nginx is very flexible with.
I fail to understand why some missing metrics in a great product make you think to migrate everything to Caddy?
My tests in controlled environments show that caddy is absolutely fine for my workload and has perks that make my life easier. Some have been mentioned in this thread already.
Metrics is a must have in our case as we have many things to manage, few people to maintain things and alerts are the only way to grow. For alerts you need metrics.
No product would ever cater to each and every need, and that's fine.
You have choice, if something doesn't satisfy you, you can sometimes fix the problem, improve the product or write your own module (when its opensource), or switch to another solution. Look at the opentelemetry comment below as another possibility to get what you want done.
There are so many choices today, and you enjoy the freedom of choice. If something else works better for you, use that other something.
There's no need to complain.
Not sure about the status quo in NGINX. They had a HTTP/3 implementation on Quiche (a Rust lib implementing QUIC, and HTTP/3 as a side project, but afik NGINX never used that part, only the QUIC protocol implementation). But after reading a post here I'm not sure they still use Quiche (and with it BoringSSL). Maybe they have now an own QUIC implementation (with support for other crypto libs). But given QUIC is complex and therefore hard to implement I would actually expect they still base of their HTTP/3 efforts on the by now quite popular Quiche library. But I'm maybe wrong in this regard. Have to look into that.
AFAIK that was a Cloudflare project, and since then they moved away from nginx due to it's stagnation.
Footnote: I actually love musl, just for my own software that explicitly targets it and is validated against it.
Most software isn't written with Musl in mind! And that shows.
You can run in all kinds of extremely hard to debug issues and especially massive performance problems. Stuff may slow down to fractions of the performance comparison to regular Linux distros.
If you want maximal small containers go with Distroless.
QUIC: https://en.wikipedia.org/wiki/QUIC
DoQ: DNS-over-QUIC: https://en.wikipedia.org/wiki/Domain_Name_System#Transport_p...
RFC9520: DNS over Dedicated QUIC Connections: https://datatracker.ietf.org/doc/html/rfc9250
I haven't used it so I can't vouch for the quality.
Update: I guess, technically, HTTP 3 is the protocol built on top of the QUIC protocol.
[1] https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/...
[2] https://www.w3.org/2011/04/webrtc/wiki/images/6/69/Media_ove...
AFAIK nobody ever implemented WebRTC on top of QUIC. The new kid on the block is called WebTransport.
WebTransport could be described in short as "WebRTC / WebSocket, the good parts". It's way simpler than WebRTC and solves some issues with WebSocket like the lack of low-latency unreliable transport (WebTransport can send Datagrams without having to use a reliable connection channel for that). A big difference to WebRTC is: All the STUN / TURN complexity is gone. WebTransport gives you at the end more or less almost "raw" QUIC streams or datagrams. It's almost like a socket interface for web user agents, only with all the features of QUIC.
Given you have already HTTP/3 (which implies you have also QUIC) WebTransport is a pretty simple and slim addition on top:
https://datatracker.ietf.org/doc/html/draft-ietf-webtrans-ht...
(The only thing I'm missing is client authentication. It would be really good to do this in-band, and for example allow to send client certs with the WebTransport CONNECT request. For some reason this was left out on purpose. Only that I did not find out why actually.)
What I'm not sure about is who good WebTransport would be in a P2P scenario. But given libp2p implemented WebTransport it would seem that it's good for that also. (So could replace WebRTC completely.)
> it cannot establish a connection to a non-CA TLS endpoint
That's plain wrong. Self signed certificates and internal CAs work just fine.
The whole point of HTTP/3 is: You can't establish an unencrypted connection. And that's a very good idea!
I'm running at the very moment a HTTP/3 development server on this machine here. I did not have to ask anybody for allowance to do so.
(Actually I'm right now building a WebTransport server. WebTransport has even more strict rules for certificates but even there it's still possible to connect to an endpoint that uses a self-signed cert that isn't signed by any CA cert.)
Inform me then. Did you compile boringssl or openssl+quic or whatever TLS lib yourself and enable the proper flags so you could do this? You and I both know that doesn't count. You certainly can't if you're using a binary distributed browser made by Microsoft, Google, Apple, or even Mozilla. If you look at the traffic you're sending it's probably hitting the HTTP/1.1 endpoint first then going to http/3 for further traffic.
Internal CAs work but that's internal and irrelevant to being able to host a visitable website to a random persons.
>You can't establish an unencrypted connection. And that's a very good idea!
That's a very good idea for incorporated persons and their websites that involve transfers of money and other private details. The trade-off is that the entire system is more fragile and complex and needs continous constant updating and approval from a third party corporation. These are very bad traits for making a personal website that can last more than a few years. It's bad for the longevity of the web and so it's health.
While it is a performance and security burden, people reject .htaccess is too readily. It has enabled users who aren't quite programmers to assemble sites out of web applications and components that live in different subdirectories. It has clear value. (Not that I think nginx should implement it.)
In that case you would still need some way to trigger a reload of the htaccess, right?
If so, is there a usability difference to just including nginx configs on the same locations?