From 6fac846f3d48c6b957b662a443221cbe4bfb5104 Mon Sep 17 00:00:00 2001 From: qlee Date: Wed, 2 May 2018 18:32:31 +0800 Subject: [PATCH] geoip2 directive support relative path as first argument --- ngx_http_geoip2_module.c | 6 ++++++ ngx_stream_geoip2_module.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/ngx_http_geoip2_module.c b/ngx_http_geoip2_module.c index a470970..0814e5b 100644 --- a/ngx_http_geoip2_module.c +++ b/ngx_http_geoip2_module.c @@ -312,6 +312,12 @@ ngx_http_geoip2(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) value = cf->args->elts; + if (value[1].data && value[1].data[0] != '/') { + if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) { + return NGX_CONF_ERROR; + } + } + if (gcf->databases == NULL) { gcf->databases = ngx_array_create(cf->pool, 2, sizeof(ngx_http_geoip2_db_t)); diff --git a/ngx_stream_geoip2_module.c b/ngx_stream_geoip2_module.c index e7db650..1bdeff8 100644 --- a/ngx_stream_geoip2_module.c +++ b/ngx_stream_geoip2_module.c @@ -279,6 +279,12 @@ ngx_stream_geoip2(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) value = cf->args->elts; + if (value[1].data && value[1].data[0] != '/') { + if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) { + return NGX_CONF_ERROR; + } + } + if (gcf->databases == NULL) { gcf->databases = ngx_array_create(cf->pool, 2, sizeof(ngx_stream_geoip2_db_t));