How can I use varnish to generate a robots.txt file even for subdomain of the same site?

Posted by Sam on Server Fault See other posts from Server Fault or by Sam
Published on 2012-03-19T05:20:02Z Indexed on 2012/03/20 23:32 UTC
Read the original article Hit count: 457

Filed under:
|

I want to generate a robots.txt file using Varnish 2.1.

That means that domain.com/robots.txt is served using Varnish and also subdomain.domain.com/robots.txt is also served using Varnish.

The robots.txt must be hardcoded into default.vcl file. is that possible?

I know Varnish can generate a maintenance page on error. I'm trying to make it generate a robots.txt file. Can anyone help?

sub vcl_error {
     set obj.http.Content-Type = "text/html; charset=utf-8";
     synthetic {"
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html>
   <head>
     <title>Maintenance in progress</title>
   </head>
   <body>
     <h1>Maintenance in progress</h1>
   </body>
 </html>
 "};
     return (deliver);
 }

© Server Fault or respective owner

Related posts about varnish

Related posts about robots.txt