httpd: Don't emit robots.txt if there are no robots entries

This commit is contained in:
Eelco Dolstra 2014-09-18 18:48:28 +02:00
parent ee082af1e0
commit 837a0c05e5

View file

@ -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 ""}