|
96 | 96 | REDIRECT_STATUS = "200"; |
97 | 97 | }; |
98 | 98 |
|
99 | | - recommendedProxyConfig = pkgs.writeText "nginx-recommended-proxy-headers.conf" '' |
| 99 | + recommendedProxyConfig = pkgs.writeText "nginx-recommended-proxy_set_header-headers.conf" '' |
100 | 100 | proxy_set_header Host $host; |
101 | 101 | proxy_set_header X-Real-IP $remote_addr; |
102 | 102 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
240 | 240 | include ${recommendedProxyConfig}; |
241 | 241 | ''} |
242 | 242 |
|
| 243 | + ${optionalString cfg.recommendedUwsgiSettings '' |
| 244 | + uwsgi_connect_timeout ${cfg.uwsgiTimeout}; |
| 245 | + uwsgi_send_timeout ${cfg.uwsgiTimeout}; |
| 246 | + uwsgi_read_timeout ${cfg.uwsgiTimeout}; |
| 247 | + uwsgi_param HTTP_CONNECTION ""; |
| 248 | + include ${cfg.package}/conf/uwsgi_params; |
| 249 | + ''} |
| 250 | +
|
243 | 251 | ${optionalString (cfg.mapHashBucketSize != null) '' |
244 | 252 | map_hash_bucket_size ${toString cfg.mapHashBucketSize}; |
245 | 253 | ''} |
|
444 | 452 | proxy_set_header Upgrade $http_upgrade; |
445 | 453 | proxy_set_header Connection $connection_upgrade; |
446 | 454 | ''} |
| 455 | + ${optionalString (config.uwsgiPass != null && !cfg.uwsgiResolveWhileRunning) |
| 456 | + "uwsgi_pass ${config.uwsgiPass};" |
| 457 | + } |
| 458 | + ${optionalString (config.uwsgiPass != null && cfg.uwsgiResolveWhileRunning) '' |
| 459 | + set $nix_proxy_target "${config.uwsgiPass}"; |
| 460 | + uwsgi_pass $nix_proxy_target; |
| 461 | + ''} |
447 | 462 | ${concatStringsSep "\n" |
448 | 463 | (mapAttrsToList (n: v: ''fastcgi_param ${n} "${v}";'') |
449 | 464 | (optionalAttrs (config.fastcgiParams != {}) |
|
455 | 470 | ${optionalString (config.return != null) "return ${toString config.return};"} |
456 | 471 | ${config.extraConfig} |
457 | 472 | ${optionalString (config.proxyPass != null && config.recommendedProxySettings) "include ${recommendedProxyConfig};"} |
| 473 | + ${optionalString (config.uwsgiPass != null && config.recommendedUwsgiSettings) "include ${cfg.package}/conf/uwsgi_params;"} |
458 | 474 | ${mkBasicAuth "sublocation" config} |
459 | 475 | } |
460 | 476 | '') (sortProperties (mapAttrsToList (k: v: v // { location = k; }) locations))); |
|
555 | 571 | ''; |
556 | 572 | }; |
557 | 573 |
|
| 574 | + recommendedUwsgiSettings = mkOption { |
| 575 | + default = false; |
| 576 | + type = types.bool; |
| 577 | + description = '' |
| 578 | + Whether to enable recommended uwsgi settings if a vhost does not specify the option manually. |
| 579 | + ''; |
| 580 | + }; |
| 581 | + |
| 582 | + uwsgiTimeout = mkOption { |
| 583 | + type = types.str; |
| 584 | + default = "60s"; |
| 585 | + example = "20s"; |
| 586 | + description = '' |
| 587 | + Change the uwsgi related timeouts in recommendedUwsgiSettings. |
| 588 | + ''; |
| 589 | + }; |
| 590 | + |
558 | 591 | defaultListen = mkOption { |
559 | 592 | type = with types; listOf (submodule { |
560 | 593 | options = { |
|
864 | 897 | ''; |
865 | 898 | }; |
866 | 899 |
|
| 900 | + uwsgiResolveWhileRunning = mkOption { |
| 901 | + type = types.bool; |
| 902 | + default = false; |
| 903 | + description = '' |
| 904 | + Resolves domains of uwsgi targets at runtime |
| 905 | + and not only at start, you have to set |
| 906 | + services.nginx.resolver, too. |
| 907 | + ''; |
| 908 | + }; |
| 909 | + |
867 | 910 | mapHashBucketSize = mkOption { |
868 | 911 | type = types.nullOr (types.enum [ 32 64 128 ]); |
869 | 912 | default = null; |
@@ -1161,6 +1204,16 @@ in |
1161 | 1204 | ''; |
1162 | 1205 | } |
1163 | 1206 |
|
| 1207 | + { |
| 1208 | + assertion = all (host: |
| 1209 | + all (location: !(location.proxyPass != null && location.uwsgiPass != null)) (attrValues host.locations)) |
| 1210 | + (attrValues virtualHosts); |
| 1211 | + message = '' |
| 1212 | + Options services.nginx.service.virtualHosts.<name>.proxyPass and |
| 1213 | + services.nginx.virtualHosts.<name>.uwsgiPass are mutually exclusive. |
| 1214 | + ''; |
| 1215 | + } |
| 1216 | + |
1164 | 1217 | { |
1165 | 1218 | assertion = cfg.package.pname != "nginxQuic" && cfg.package.pname != "angieQuic" -> !(cfg.enableQuicBPF); |
1166 | 1219 | message = '' |
|
0 commit comments