Welcome! Log In Create A New Profile

Advanced

server_group { } directive?

January 16, 2013 06:00AM
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
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

server_group { } directive?

q42jaap January 16, 2013 06:00AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 287
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready