Skip to content

Commit ad9f038

Browse files
committed
Add client ip logging on proxy
1 parent 8b7476c commit ad9f038

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/ngx_http_redirectionio_protocol.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,11 @@ ngx_int_t ngx_http_redirectionio_protocol_send_log(ngx_connection_t *c, ngx_http
137137
}
138138

139139
ngx_http_redirectionio_log_t* ngx_http_redirectionio_protocol_create_log(ngx_http_request_t *r, ngx_http_redirectionio_ctx_t *ctx, ngx_str_t *project_key) {
140-
const char *log_serialized;
140+
const char *client_ip, *log_serialized;
141141
ngx_http_redirectionio_log_t *log;
142142

143-
log_serialized = redirectionio_api_create_log_in_json(ctx->request, r->headers_out.status, ctx->response_headers, ctx->action, PROXY_VERSION_STR(PROXY_VERSION), r->start_msec);
143+
client_ip = ngx_str_to_char(&r->connection->addr_text, r->pool);
144+
log_serialized = redirectionio_api_create_log_in_json(ctx->request, r->headers_out.status, ctx->response_headers, ctx->action, PROXY_VERSION_STR(PROXY_VERSION), r->start_msec, client_ip);
144145

145146
if (log_serialized == NULL) {
146147
return NULL;

0 commit comments

Comments
 (0)