Skip to content

[Bug] Kubernetes 배포 시 LoggingMiddleware이 실제 IP를 추적하지 못함 #14

@Zerohertz

Description

@Zerohertz

What happened?

Kubernetes를 통해 배포했을 때 middleware가 요청의 IP를 출력하지 못함

Relevant log output

https://github.com/Zerohertz/fastapi-boilerplate/blob/a1e0486dc36719d86c8a9bd65212db1144532d95/app/core/middlewares.py#L14-L21

2025-01-15 21:33:57.253 KST | INFO     | app.core.middlewares:dispatch:37 - [IP: 192.168.208.121:39444] [URL: http://api.zerohertz.xyz/v1/shields/jmy] [Method: GET] [Status: Processing...]
2025-01-15 21:33:57.253 KST | INFO     | app.core.middlewares:dispatch:51 - [IP: 192.168.208.121:39444] [URL: http://api.zerohertz.xyz/v1/shields/jmy] [Method: GET] [Status: 200 (Elapsed Time: 0.000s)]
2025-01-15 21:34:09.107 KST | INFO     | app.core.middlewares:dispatch:37 - [IP: 192.168.208.121:38392] [URL: http://api.zerohertz.xyz/docs] [Method: GET] [Status: Processing...]
2025-01-15 21:34:09.107 KST | INFO     | app.core.middlewares:dispatch:51 - [IP: 192.168.208.121:38392] [URL: http://api.zerohertz.xyz/docs] [Method: GET] [Status: 200 (Elapsed Time: 0.000s)]
2025-01-15 21:34:09.258 KST | INFO     | app.core.middlewares:dispatch:37 - [IP: 192.168.208.121:38392] [URL: http://api.zerohertz.xyz/openapi.json] [Method: GET] [Status: Processing...]
2025-01-15 21:34:09.259 KST | INFO     | app.core.middlewares:dispatch:51 - [IP: 192.168.208.121:38392] [URL: http://api.zerohertz.xyz/openapi.json] [Method: GET] [Status: 200 (Elapsed Time: 0.000s)]
2025-01-15 21:34:12.098 KST | INFO     | app.core.middlewares:dispatch:37 - [IP: 192.168.208.121:38392] [URL: http://api.zerohertz.xyz/docs] [Method: GET] [Status: Processing...]
2025-01-15 21:34:12.099 KST | INFO     | app.core.middlewares:dispatch:51 - [IP: 192.168.208.121:38392] [URL: http://api.zerohertz.xyz/docs] [Method: GET] [Status: 200 (Elapsed Time: 0.000s)]
2025-01-15 21:34:12.178 KST | INFO     | app.core.middlewares:dispatch:37 - [IP: 192.168.208.121:38392] [URL: http://api.zerohertz.xyz/openapi.json] [Method: GET] [Status: Processing...]
2025-01-15 21:34:12.179 KST | INFO     | app.core.middlewares:dispatch:51 - [IP: 192.168.208.121:38392] [URL: http://api.zerohertz.xyz/openapi.json] [Method: GET] [Status: 200 (Elapsed Time: 0.000s)]
2025-01-15 21:34:20.514 KST | INFO     | app.core.middlewares:dispatch:37 - [IP: 192.168.208.121:51208] [URL: http://api.zerohertz.xyz/v1/shields/jmy] [Method: GET] [Status: Processing...]
2025-01-15 21:34:20.514 KST | INFO     | app.core.middlewares:dispatch:51 - [IP: 192.168.208.121:51208] [URL: http://api.zerohertz.xyz/v1/shields/jmy] [Method: GET] [Status: 200 (Elapsed Time: 0.000s)]
2025-01-15 21:34:20.827 KST | INFO     | app.core.middlewares:dispatch:37 - [IP: 192.168.208.121:51208] [URL: http://api.zerohertz.xyz/favicon.ico] [Method: GET] [Status: Processing...]
2025-01-15 21:34:20.828 KST | INFO     | app.core.middlewares:dispatch:51 - [IP: 192.168.208.121:51208] [URL: http://api.zerohertz.xyz/favicon.ico] [Method: GET] [Status: 404 (Elapsed Time: 0.000s)]
2025-01-15 21:35:03.219 KST | INFO     | app.core.middlewares:dispatch:37 - [IP: 192.168.208.121:34626] [URL: http://api.zerohertz.xyz/docs] [Method: GET] [Status: Processing...]
2025-01-15 21:35:03.219 KST | INFO     | app.core.middlewares:dispatch:51 - [IP: 192.168.208.121:34626] [URL: http://api.zerohertz.xyz/docs] [Method: GET] [Status: 200 (Elapsed Time: 0.000s)]
2025-01-15 21:35:03.318 KST | INFO     | app.core.middlewares:dispatch:37 - [IP: 192.168.208.121:34626] [URL: http://api.zerohertz.xyz/openapi.json] [Method: GET] [Status: Processing...]
2025-01-15 21:35:03.319 KST | INFO     | app.core.middlewares:dispatch:51 - [IP: 192.168.208.121:34626] [URL: http://api.zerohertz.xyz/openapi.json] [Method: GET] [Status: 200 (Elapsed Time: 0.000s)]

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions