Get IP of the original client when querying /verify.

This commit is contained in:
Clement Michaud 2018-08-28 22:05:59 +02:00 committed by Clément Michaud
parent 64f28379ac
commit 91763e97a1
2 changed files with 7 additions and 2 deletions

View File

@ -80,6 +80,7 @@ http {
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
@ -147,6 +148,7 @@ http {
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
@ -197,6 +199,7 @@ http {
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
@ -247,6 +250,7 @@ http {
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
@ -298,6 +302,7 @@ http {
proxy_set_header X-Original-URL $scheme://$http_host$request_uri;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# This header is required for basic authentication.
proxy_set_header Proxy-Authorization $http_authorization;

View File

@ -17,9 +17,9 @@ export class RequestLogger implements IRequestLogger {
}
private formatHeader(req: Express.Request) {
const ip = req.headers["x-forwarded-for"] || req.connection.remoteAddress;
const clientIP = req.ip; // The IP of the original client going through the proxy chain.
return Util.format("date='%s' method='%s', path='%s' requestId='%s' sessionId='%s' ip='%s'",
new Date(), req.method, req.path, req.id, req.sessionID, ip);
new Date(), req.method, req.path, req.id, req.sessionID, clientIP);
}
private formatBody(message: string) {