Skip to content

Commit d32f7eb

Browse files
authored
Merge pull request #204 from os2display/hotfix/ip-logging
1185: Ensured real ip is logged in nginx
2 parents 91d8bc2 + ae0ca46 commit d32f7eb

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
- [#204](https://github.com/os2display/display-api-service/pull/204)
8+
- Ensured real ip is logged in nginx.
79
- [#200](https://github.com/os2display/display-api-service/pull/200)
810
- Updated oidc internal documentation.
911
- [#205](https://github.com/os2display/display-api-service/pull/205)

infrastructure/itkdev/nginx/etc/confd/templates/nginx.conf.tmpl

+5-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ http {
3737
include /etc/nginx/mime.types;
3838
default_type application/octet-stream;
3939

40-
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
40+
set_real_ip_from 172.16.0.0/8;
41+
real_ip_recursive on;
42+
real_ip_header X-Forwarded-For;
43+
44+
log_format main '$http_x_real_ip - $remote_user [$time_local] "$request" '
4145
'$status $body_bytes_sent "$http_referer" '
4246
'"$http_user_agent" "$http_x_forwarded_for"';
4347

infrastructure/os2display/nginx/etc/confd/templates/nginx.conf.tmpl

+5-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,13 @@ http {
3737
include /etc/nginx/mime.types;
3838
default_type application/octet-stream;
3939

40-
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
40+
set_real_ip_from 172.16.0.0/8;
41+
real_ip_recursive on;
42+
real_ip_header X-Forwarded-For;
43+
44+
log_format main '$http_x_real_ip - $remote_user [$time_local] "$request" '
4145
'$status $body_bytes_sent "$http_referer" '
4246
'"$http_user_agent" "$http_x_forwarded_for"';
43-
4447
error_log /dev/stderr;
4548
access_log /dev/stdout main;
4649

0 commit comments

Comments
 (0)