-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
nixos/nginx: fix config validation with hostnames in proxy_pass #207413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
16d07f4
db13557
ce4ebbb
6c2d4c7
c00e3a0
65cba21
826c415
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -401,25 +401,68 @@ let | |||||||||||||||||||||||||
| openssl req -new -key $out/server.key -out server.csr \ | ||||||||||||||||||||||||||
| -subj "/C=UK/ST=Warwickshire/L=Leamington/O=OrgName/OU=IT Department/CN=example.com" | ||||||||||||||||||||||||||
| openssl x509 -req -days 1 -in server.csr -signkey $out/server.key -out $out/server.crt | ||||||||||||||||||||||||||
| openssl dhparam -out $out/dhparam.pem 1024 | ||||||||||||||||||||||||||
| ''; | ||||||||||||||||||||||||||
| validatedConfigFile = pkgs.runCommand "validated-nginx.conf" { nativeBuildInputs = [ cfg.package ]; } '' | ||||||||||||||||||||||||||
| fakednsConfig = builtins.toFile "fakednsConfig" '' | ||||||||||||||||||||||||||
| [Settings] | ||||||||||||||||||||||||||
| ListenOnPort = 53 | ||||||||||||||||||||||||||
| [DomainPattern] | ||||||||||||||||||||||||||
| name_pattern = * | ||||||||||||||||||||||||||
| answer_A = 192.168.42.42 | ||||||||||||||||||||||||||
| answer_AAAA = fdac:3d9f:2940:bddd::1 | ||||||||||||||||||||||||||
| ''; | ||||||||||||||||||||||||||
| nginxWithResolver = pkgs.writeShellScript "nginxWithResolver" '' | ||||||||||||||||||||||||||
| set -e | ||||||||||||||||||||||||||
| fakedns --config ${fakednsConfig} & | ||||||||||||||||||||||||||
| # wait for the server to be ready | ||||||||||||||||||||||||||
| for i in $(seq 1 1000); do | ||||||||||||||||||||||||||
| if getent hosts foo.bar; then | ||||||||||||||||||||||||||
| break | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| sleep 1 | ||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||
| nginx -t -c /etc/nginx.conf || true | ||||||||||||||||||||||||||
| ''; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| validatedConfigFile = pkgs.runCommand "validated-nginx.conf" { nativeBuildInputs = [ cfg.package pkgs.bubblewrap pkgs.fakedns pkgs.getent ]; } '' | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| 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 ]; | |
| } '' |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||||||||||||
| { buildPythonPackage, fetchPypi, lib }: | ||||||||||||||||
| buildPythonPackage rec { | ||||||||||||||||
|
||||||||||||||||
| { buildPythonPackage, fetchPypi, lib }: | |
| buildPythonPackage rec { | |
| { buildPythonPackage, fetchPypi, lib }: | |
| buildPythonPackage rec { |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # has no tests | |
| doCheck = false; | |
| pythonImportsCheck = [ "cli_formatter" ]; | |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||||||
| { buildPythonPackage, fetchPypi, lib }: | ||||||||||
|
|
||||||||||
| buildPythonPackage rec { | ||||||||||
| pname = "dns-messages"; | ||||||||||
| version = "1.0.0"; | ||||||||||
|
|
||||||||||
| src = fetchPypi { | ||||||||||
| inherit pname version; | ||||||||||
| sha256 = "sha256-00gjYwEUeizid/kXxGV2WjBzO/PCpDjV2hMmYUdjPd4="; | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| # has no tests | ||||||||||
| doCheck = false; | ||||||||||
|
||||||||||
| doCheck = false; | |
| # has no tests | |
| doCheck = false; |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| pythonImportsCheck = [ "dns_messages" ]; | |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { python3, fetchFromGitHub, lib }: | ||
|
|
||
| python3.pkgs.buildPythonApplication { | ||
| pname = "fakedns"; | ||
| version = "2022-08-14"; | ||
|
|
||
| src = fetchFromGitHub { | ||
| owner = "wahlflo"; | ||
| repo = "fakedns"; | ||
| rev = "11397c3e5180f30de184fba1dbfe9fc8ea85fadd"; | ||
| sha256 = "sha256-ZGNZ8pa9loSTDqrx3ra7sRfsDKzJ1Z2UDlsg+qGq9xo="; | ||
| }; | ||
|
|
||
| propagatedBuildInputs = with python3.pkgs; [ | ||
| cli-formatter | ||
| dns-messages | ||
| ]; | ||
|
|
||
| pythonImportsCheck = [ "fakedns" ]; | ||
|
|
||
| meta = { | ||
| description = "A fake DNS server for malware analysis"; | ||
| homepage = "https://github.com/wahlflo/fakedns"; | ||
| license = [ lib.licenses.mit ]; | ||
| maintainers = [ lib.maintainers.symphorien ]; | ||
| }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waiting 1000 seconds for that to come up is to long