leev / ngx_http_geoip2_module

Nginx GeoIP2 module
BSD 2-Clause "Simplified" License
960 stars 182 forks source link

Server directive #7

Closed timk95 closed 10 years ago

timk95 commented 10 years ago

Why not allow this module to be used in the server directive? Is there any particular reason not to? For example a static file domain doesn't have any benefit from knowing the country of a visitor.

leev commented 10 years ago

The module was based around the original geoip module included with nginx, and works in the same way.

In your example, if the static file domain doesn't require the country, then if you don't reference any of the geoip2 variables, it won't be used, so nothing is lost. An ip lookup is only performed if one (or more) of the variables are accessed during the request. So I'm unsure as to what will be achieved by moving this into the server block.

ghprince commented 7 years ago

performance-wise it is the same, but having it enabled in server block or even location block will give us better code organization

If only one location needs it, these geoip2 blocks can be put into the partial of that location.