Hey there,
I was reading about global if's / locations and why it isn't possible.
I would like to suggest the following, maybe it's been suggested
before, who knows:
server_group {
# this if will be duplicated to each of the server { } configs in
this server_group
if ( $http_user_agent ~* Googlebot ) {
return 403;
}
server {
server_name srv1.example.com;
}
server {
server_name srv2.example.com;
}
}
It's just a way for me to keep the server { } configs very simple,
runtime it should be just like the if would appear twice. With
includes this makes more sense:
nginx.conf:
server_group {
# this if will be duplicated to each of the server { } configs in
this server_group
if ( $http_user_agent ~* Googlebot ) {
return 403;
}
include protected-servers/*.conf;
}
protected-servers/srv1.conf:
server {
server_name srv1.example.com;
}
protected-servers/srv2.conf:
server {
server_name srv2.example.com;
}
This way I can enforce the servers in protected-server/*.conf to have
the googlebot check. Otherwise I would have to include a file in each
.conf file, which could lead to human mistakes.
Jaap
on 2013-01-16 11:59
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.