Skip to content

Commit cbaa354

Browse files
authored
Merge pull request #110 from hnakamur/update_for_nginx_1_23_0
Update xfwd type changed in nginx 1.23.0 (Fixes #109)
2 parents 58b92be + 8cba01c commit cbaa354

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ngx_http_geoip2_module.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ ngx_http_geoip2_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
146146
MMDB_entry_data_s entry_data;
147147
ngx_http_geoip2_conf_t *gcf;
148148
ngx_addr_t addr;
149+
#if defined(nginx_version) && nginx_version >= 1023000
150+
ngx_table_elt_t *xfwd;
151+
#else
149152
ngx_array_t *xfwd;
153+
#endif
150154
u_char *p;
151155
ngx_str_t val;
152156

@@ -169,9 +173,15 @@ ngx_http_geoip2_variable(ngx_http_request_t *r, ngx_http_variable_value_t *v,
169173
addr.sockaddr = r->connection->sockaddr;
170174
addr.socklen = r->connection->socklen;
171175

176+
#if defined(nginx_version) && nginx_version >= 1023000
177+
xfwd = r->headers_in.x_forwarded_for;
178+
179+
if (xfwd != NULL && gcf->proxies != NULL) {
180+
#else
172181
xfwd = &r->headers_in.x_forwarded_for;
173182

174183
if (xfwd->nelts > 0 && gcf->proxies != NULL) {
184+
#endif
175185
(void) ngx_http_get_forwarded_addr(r, &addr, xfwd, NULL,
176186
gcf->proxies, gcf->proxy_recursive);
177187
}

0 commit comments

Comments
 (0)