Compare commits
10 commits
1cabd8a1f6
...
a607a41a81
Author | SHA1 | Date | |
---|---|---|---|
|
a607a41a81 | ||
|
df09bbb10a | ||
|
cbaa35461c | ||
|
8cba01cd27 | ||
|
58b92befd7 | ||
|
cb416a68c1 | ||
|
a26c6beed7 | ||
|
8c780510ea | ||
|
1f216031a9 | ||
|
d66d89b4d7 |
2 changed files with 35 additions and 2 deletions
25
README.md
25
README.md
|
@ -7,7 +7,7 @@ The module now supports nginx streams and can be used in the same way the http m
|
|||
|
||||
## Installing
|
||||
First install [libmaxminddb](https://github.com/maxmind/libmaxminddb) as described in its [README.md
|
||||
file](https://github.com/maxmind/libmaxminddb/blob/master/README.md#installing-from-a-tarball).
|
||||
file](https://github.com/maxmind/libmaxminddb/blob/main/README.md#installing-from-a-tarball).
|
||||
|
||||
#### Download nginx source
|
||||
```
|
||||
|
@ -37,6 +37,14 @@ make
|
|||
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)
|
||||
The free GeoLite2 databases are available from [Maxminds website](http://dev.maxmind.com/geoip/geoip2/geolite2/) (requires signing up)
|
||||
|
||||
|
@ -128,3 +136,18 @@ This translates to:
|
|||
```
|
||||
$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.
|
||||
|
|
|
@ -146,7 +146,11 @@ ngx_http_geoip2_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
|||
MMDB_entry_data_s entry_data;
|
||||
ngx_http_geoip2_conf_t *gcf;
|
||||
ngx_addr_t addr;
|
||||
#if defined(nginx_version) && nginx_version >= 1023000
|
||||
ngx_table_elt_t *xfwd;
|
||||
#else
|
||||
ngx_array_t *xfwd;
|
||||
#endif
|
||||
u_char *p;
|
||||
ngx_str_t val;
|
||||
|
||||
|
@ -169,9 +173,15 @@ ngx_http_geoip2_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
|
|||
addr.sockaddr = r->connection->sockaddr;
|
||||
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;
|
||||
|
||||
if (xfwd->nelts > 0 && gcf->proxies != NULL) {
|
||||
#endif
|
||||
(void) ngx_http_get_forwarded_addr(r, &addr, xfwd, NULL,
|
||||
gcf->proxies, gcf->proxy_recursive);
|
||||
}
|
||||
|
@ -441,7 +451,7 @@ ngx_http_geoip2_parse_config(ngx_conf_t *cf, ngx_command_t *dummy, void *conf)
|
|||
if (interval == (time_t) NGX_ERROR) {
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"invalid interval for auto_reload \"%V\"",
|
||||
value[1]);
|
||||
&value[1]);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue