at 25.11-pre 691 B view raw
1{ lib, ... }: 2{ 3 name = "nginx-redirectcode"; 4 meta.maintainers = with lib.maintainers; [ misterio77 ]; 5 6 nodes = { 7 webserver = 8 { pkgs, lib, ... }: 9 { 10 services.nginx = { 11 enable = true; 12 virtualHosts.localhost = { 13 globalRedirect = "example.com/foo"; 14 # With 308 (and 307), the method and body are to be kept when following it 15 redirectCode = 308; 16 }; 17 }; 18 }; 19 }; 20 21 testScript = '' 22 webserver.wait_for_unit("nginx") 23 webserver.wait_for_open_port(80) 24 25 # Check the status code 26 webserver.succeed("curl -si http://localhost | grep '^HTTP/[0-9.]\+ 308 Permanent Redirect'") 27 ''; 28}