Compare commits

..

No commits in common. "a607a41a8115fecfc05b5c283c81532a3d605425" and "1cabd8a1f68ea3998f94e9f3504431970f848fbf" have entirely different histories.

2 changed files with 2 additions and 35 deletions

View file

@ -7,7 +7,7 @@ The module now supports nginx streams and can be used in the same way the http m
## Installing ## Installing
First install [libmaxminddb](https://github.com/maxmind/libmaxminddb) as described in its [README.md First install [libmaxminddb](https://github.com/maxmind/libmaxminddb) as described in its [README.md
file](https://github.com/maxmind/libmaxminddb/blob/main/README.md#installing-from-a-tarball). file](https://github.com/maxmind/libmaxminddb/blob/master/README.md#installing-from-a-tarball).
#### Download nginx source #### Download nginx source
``` ```
@ -37,14 +37,6 @@ make
make install make install
``` ```
##### If you need stream support, make sure to compile with stream:
```
./configure --add-dynamic-module=/path/to/ngx_http_geoip2_module --with-stream
OR
./configure --add-module=/path/to/ngx_http_geoip2_module --with-stream
```
## Download Maxmind GeoLite2 Database (optional) ## Download Maxmind GeoLite2 Database (optional)
The free GeoLite2 databases are available from [Maxminds website](http://dev.maxmind.com/geoip/geoip2/geolite2/) (requires signing up) The free GeoLite2 databases are available from [Maxminds website](http://dev.maxmind.com/geoip/geoip2/geolite2/) (requires signing up)
@ -136,18 +128,3 @@ This translates to:
``` ```
$country_name "default=United States" source=$remote_addr country names en $country_name "default=United States" source=$remote_addr country names en
``` ```
##### Additional Commands:
These commands works the same as the original ngx_http_geoip_module documented here: http://nginx.org/en/docs/http/ngx_http_geoip_module.html#geoip_proxy.
However, if you provide the `source=$variable_with_ip` option on a variable, these settings will be ignored for that particular variable.
```
geoip2_proxy < cidr >
```
Defines trusted addresses. When a request comes from a trusted address, an address from the "X-Forwarded-For" request header field will be used instead.
```
geoip2_proxy_recursive < on | off >
```
If recursive search is disabled then instead of the original client address that matches one of the trusted addresses, the last address sent in "X-Forwarded-For" will be used. If recursive search is enabled then instead of the original client address that matches one of the trusted addresses, the last non-trusted address sent in "X-Forwarded-For" will be used.

View file

@ -146,11 +146,7 @@ ngx_http_geoip2_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
MMDB_entry_data_s entry_data; MMDB_entry_data_s entry_data;
ngx_http_geoip2_conf_t *gcf; ngx_http_geoip2_conf_t *gcf;
ngx_addr_t addr; ngx_addr_t addr;
#if defined(nginx_version) && nginx_version >= 1023000
ngx_table_elt_t *xfwd;
#else
ngx_array_t *xfwd; ngx_array_t *xfwd;
#endif
u_char *p; u_char *p;
ngx_str_t val; ngx_str_t val;
@ -173,15 +169,9 @@ ngx_http_geoip2_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
addr.sockaddr = r->connection->sockaddr; addr.sockaddr = r->connection->sockaddr;
addr.socklen = r->connection->socklen; addr.socklen = r->connection->socklen;
#if defined(nginx_version) && nginx_version >= 1023000
xfwd = r->headers_in.x_forwarded_for;
if (xfwd != NULL && gcf->proxies != NULL) {
#else
xfwd = &r->headers_in.x_forwarded_for; xfwd = &r->headers_in.x_forwarded_for;
if (xfwd->nelts > 0 && gcf->proxies != NULL) { if (xfwd->nelts > 0 && gcf->proxies != NULL) {
#endif
(void) ngx_http_get_forwarded_addr(r, &addr, xfwd, NULL, (void) ngx_http_get_forwarded_addr(r, &addr, xfwd, NULL,
gcf->proxies, gcf->proxy_recursive); gcf->proxies, gcf->proxy_recursive);
} }
@ -451,7 +441,7 @@ ngx_http_geoip2_parse_config(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
if (interval == (time_t) NGX_ERROR) { if (interval == (time_t) NGX_ERROR) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"invalid interval for auto_reload \"%V\"", "invalid interval for auto_reload \"%V\"",
&value[1]); value[1]);
return NGX_CONF_ERROR; return NGX_CONF_ERROR;
} }