mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 07:00:43 +00:00
httpd: Don't emit robots.txt if there are no robots entries
This commit is contained in:
parent
ee082af1e0
commit
837a0c05e5
|
@ -208,16 +208,11 @@ let
|
|||
</Directory>
|
||||
'';
|
||||
|
||||
robotsTxt = pkgs.writeText "robots.txt" ''
|
||||
${# If this is a vhost, the include the entries for the main server as well.
|
||||
if isMainServer then ""
|
||||
else concatMapStrings (svc: svc.robotsEntries) mainSubservices}
|
||||
${concatMapStrings (svc: svc.robotsEntries) subservices}
|
||||
'';
|
||||
|
||||
robotsConf = ''
|
||||
Alias /robots.txt ${robotsTxt}
|
||||
'';
|
||||
robotsTxt =
|
||||
concatStringsSep "\n" (
|
||||
# If this is a vhost, the include the entries for the main server as well.
|
||||
(if isMainServer then [] else map (svc: svc.robotsEntries) mainSubservices)
|
||||
++ (map (svc: svc.robotsEntries) subservices));
|
||||
|
||||
in ''
|
||||
ServerName ${serverInfo.canonicalName}
|
||||
|
@ -245,7 +240,9 @@ let
|
|||
CustomLog ${mainCfg.logDir}/access_log-${cfg.hostName} ${cfg.logFormat}
|
||||
'' else ""}
|
||||
|
||||
${robotsConf}
|
||||
${optionalString (robotsTxt != "") ''
|
||||
Alias /robots.txt ${pkgs.writeText "robots.txt" robotsTxt}
|
||||
''}
|
||||
|
||||
${if isMainServer || maybeDocumentRoot != null then documentRootConf else ""}
|
||||
|
||||
|
|
Loading…
Reference in a new issue