6 messages in ru.sysoev.nginxRe: Serving an alternate robots.txt f...
FromSent OnAttachments
Juan Fco. GiordanaJan 13, 2009 3:14 pm 
Dave CheneyJan 13, 2009 3:58 pm 
Juan Fco. GiordanaJan 13, 2009 6:54 pm 
Igor SysoevJan 13, 2009 10:57 pm 
Dave CheneyJan 14, 2009 12:38 am 
Juan Fco. GiordanaJan 14, 2009 3:38 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Serving an alternate robots.txt for SSL requests.Actions...
From:Igor Sysoev (is@rambler-co.ru)
Date:Jan 13, 2009 10:57:28 pm
List:ru.sysoev.nginx

On Tue, Jan 13, 2009 at 09:15:07PM -0200, Juan Fco. Giordana wrote:

Thank you Nick for your help,

I've followed your suggestions and it worked as expected.

I've changed the rewrite rule since I don't need to capture anything there.

server { listen 443; [...] location = /robots.txt { rewrite ^ /robots_ssl.txt last; } }

Does anybody know if this is possible to do within a single server context that handle both protocols in version 0.7.*?

If your servers are different only in this part, then in 0.7 you can

server { listen 80; listen 443 default ssl;

location = /robots.txt { if ($server_port = 443) { # or ($scheme = https) rewrite ^ /robots_ssl.txt last; # or "break;" } }

...

If the servers have many differences, then it's better to use separate servers. In this case you do not need rewrite, use just alias:

server { listen 443;

location = /robots.txt { alias /path/to/robots_ssl.txt; }

Yet another way (the better than with if/rewrite):

map $scheme $robots { default robots.txt; https robots_ssl.txt; }

server { listen 80; listen 443 default ssl;

location = /robots.txt { alias /path/to/$robots; }

Thanks.

On 2009-01-07 15:23:26 Nick Pearson wrote:

Hi Juan,

Try using two server directives -- one for http and one for https. The server directive chosen depends on the port that is requested. Something like this:

server { listen 80; # http server_name www.yoursite.com; [...] location /robots.txt { break; } } server { listen 443; # https server_name www.yoursite.com; [...] location /robots.txt { rewrite (.*) /robots_ssl.txt; } }