From 820a232a960185f616a7957348926fb04bbef027 Mon Sep 17 00:00:00 2001 From: Lorenz Stechauner Date: Fri, 8 Jan 2021 19:59:18 +0100 Subject: [PATCH] Sending X-Forwarded-For --- src/client.c | 4 +--- src/necronda-server.h | 2 ++ src/rev_proxy.c | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/client.c b/src/client.c index e74b1c4..6c6678c 100644 --- a/src/client.c +++ b/src/client.c @@ -13,9 +13,7 @@ int server_keep_alive = 1; -char *client_addr_str, *client_addr_str_ptr, *server_addr_str, *server_addr_str_ptr, - *log_client_prefix, *log_conn_prefix, *log_req_prefix, - *client_host_str, *client_geoip; +char *log_client_prefix, *log_conn_prefix, *log_req_prefix, *client_geoip; struct timeval client_timeout = {.tv_sec = CLIENT_TIMEOUT, .tv_usec = 0}; diff --git a/src/necronda-server.h b/src/necronda-server.h index 9fb6b64..0e5ee7d 100644 --- a/src/necronda-server.h +++ b/src/necronda-server.h @@ -81,4 +81,6 @@ int sockets[NUM_SOCKETS]; pid_t children[MAX_CHILDREN]; MMDB_s mmdbs[MAX_MMDB]; +char *client_addr_str, *client_addr_str_ptr, *server_addr_str, *server_addr_str_ptr, *client_host_str; + #endif //NECRONDA_SERVER_NECRONDA_SERVER_H diff --git a/src/rev_proxy.c b/src/rev_proxy.c index bc46c61..2f14a24 100644 --- a/src/rev_proxy.c +++ b/src/rev_proxy.c @@ -99,6 +99,8 @@ int rev_proxy_init(http_req *req, http_res *res, host_config *conf, sock *client rev_proxy: http_remove_header_field(&req->hdr, "Connection", HTTP_REMOVE_ALL); http_add_header_field(&req->hdr, "Connection", "keep-alive"); + http_remove_header_field(&req->hdr, "X-Forwarded-For", HTTP_REMOVE_ALL); + http_add_header_field(&req->hdr, "X-Forwarded-For", client_addr_str); ret = http_send_request(&rev_proxy, req); if (ret < 0) {