nixos/nginx: fix config validation with hostnames in proxy_pass#207413
nixos/nginx: fix config validation with hostnames in proxy_pass#207413symphorien wants to merge 7 commits intoNixOS:masterfrom
Conversation
6e9078c to
f56c90b
Compare
|
now works with user namespaces disabled |
SuperSandro2000
left a comment
There was a problem hiding this comment.
There is not an easier way to run config validation?
We are getting into territoriality where the overhead and workarounds are eventually outweighing the benefits.
There was a problem hiding this comment.
| ]; | |
| meta = { | |
| ]; | |
| pythonImportsCheck = [ "fakedns" ]; | |
| meta = { |
There was a problem hiding this comment.
| pythonImportsCheck = [ "dns_messages" ]; | |
There was a problem hiding this comment.
| doCheck = false; | |
| # has no tests | |
| doCheck = false; |
There was a problem hiding this comment.
| { buildPythonPackage, fetchPypi, lib }: | |
| buildPythonPackage rec { | |
| { buildPythonPackage, fetchPypi, lib }: | |
| buildPythonPackage rec { |
There was a problem hiding this comment.
| # has no tests | |
| doCheck = false; | |
| pythonImportsCheck = [ "cli_formatter" ]; | |
There was a problem hiding this comment.
| userns=yes; | |
| $bwrun ${nginxWithResolver} > out 2>&1; | |
| else | |
| userns=no; | |
| echo "user namespaces are not available, dns resolution will fail if required"; | |
| nginx -t -c $(readlink -f ./conf) > out 2>&1 || true; | |
| userns=yes | |
| $bwrun ${nginxWithResolver} > out 2>&1 | |
| else | |
| userns=no | |
| echo "user namespaces are not available, dns resolution will fail if required" | |
| nginx -t -c $(readlink -f ./conf) > out 2>&1 || true |
There was a problem hiding this comment.
| validatedConfigFile = pkgs.runCommand "validated-nginx.conf" { nativeBuildInputs = [ cfg.package pkgs.bubblewrap pkgs.fakedns pkgs.getent ]; } '' | |
| validatedConfigFile = pkgs.runCommand "validated-nginx.conf" { | |
| nativeBuildInputs = with pkgs; [ cfg.package bubblewrap fakedns getent ]; | |
| } '' |
There was a problem hiding this comment.
| for i in $(seq 1 1000); do | |
| for i in $(seq 1 30); do |
waiting 1000 seconds for that to come up is to long
There was a problem hiding this comment.
We should use private addresses or if there are some to be not resolveable them.
f56c90b to
db13557
Compare
|
I pushed changes which
Yes. I started #205561 because nixcloud-webservice has been doing such a validation since quite a long time, but it turns out it is pretty limited for more diverse configs. I can make it work with what is arguably an ugly pile of hacks. If you think this is too hacky, we can revert introducing the validation. I am also hesitating, other opinions welcome. |
To be honest the cleanest solution would probably be to change the nginx code to better fit our usecase and try to upstream that. |
|
TBH, that's not something I'm willing to attempt. |
|
superseded by #209075 |
Description of changes
There are actually many directives which trigger domain name resolution, so using regexes to "fix" them all does not seem like a good approach. Instead I run a fake dns server that answers all requests with a dummy IP.
Unfortunately libredirect tricks to point nginx to a fake /etc/resolv.conf don't work, because nginx uses getaddrinfo, so it is glibc which reads /etc/resolv.conf, and one cannot fake glibc calls to glibc it seems.
So I use bubblewrap instead, but that requires user namespaces, which are not always available. If this is not the case, and validation fails on dns failure, then we ignore the failure. The goal is that if it builds somewhere, it builds everywhere (use case: heterogenous remote builders). I have not yet tested building without user namespaces.
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notescc @delroth