Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have docker nginx logs print the client IP #328

Merged
merged 2 commits into from
Apr 8, 2024
Merged

Have docker nginx logs print the client IP #328

merged 2 commits into from
Apr 8, 2024

Conversation

joecorall
Copy link
Contributor

@joecorall joecorall commented Mar 14, 2024

Use realip nginx module to have docker logs print the client IP in its logs rather than the traefik private IP.

I made this code change in the GitHub Cloud IDE and inadvertently committed to the main branch: 78ab2d5 which I then reverted 95ecba3 (and canceled the GitHub Actions). Should we prevent direct pushes to main in this repo without a PR? When I clicked the "Commit" button in the GitHub IDE I thought it was going to prompt me to enter a branch name is how I made the mistake.

Before

$ docker compose logs drupal-prod --tail 5

172.24.0.15 - - [14/Mar/2024:13:57:56 +0000] "GET / HTTP/1.1" 200 47208 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36" "1.2.3.4"
172.24.0.15 - - [14/Mar/2024:14:11:44 +0000] "GET / HTTP/1.1" 200 47208 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15" "4.3.2.1"
172.24.0.15 - - [14/Mar/2024:14:13:21 +0000] "GET / HTTP/1.1" 200 47208 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" "13.4.5.6"
172.24.0.15 - - [14/Mar/2024:14:26:24 +0000] "GET / HTTP/1.1" 200 47208 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" "1.2.3.5"
172.24.0.15 - - [14/Mar/2024:14:32:29 +0000] "GET / HTTP/1.1" 200 47208 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" "7.8.9.9"

After

$ docker compose logs drupal-prod --tail 5

1.2.3.4 - - [14/Mar/2024:13:57:56 +0000] "GET / HTTP/1.1" 200 47208 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36" "1.2.3.4"
4.3.2.1 - - [14/Mar/2024:14:11:44 +0000] "GET / HTTP/1.1" 200 47208 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Safari/605.1.15" "4.3.2.1"
13.4.5.6 - - [14/Mar/2024:14:13:21 +0000] "GET / HTTP/1.1" 200 47208 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" "13.4.5.6"
1.2.3.5 - - [14/Mar/2024:14:26:24 +0000] "GET / HTTP/1.1" 200 47208 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" "1.2.3.5"
7.8.9.9 - - [14/Mar/2024:14:32:29 +0000] "GET / HTTP/1.1" 200 47208 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36" "7.8.9.9"

@joecorall joecorall changed the title have docker nginx logs print the client IP Have docker nginx logs print the client IP Mar 14, 2024
@aOelschlager aOelschlager self-requested a review March 20, 2024 17:35
@nigelgbanks
Copy link
Contributor

Nice work, especially adding the test!

@nigelgbanks nigelgbanks merged commit c620f62 into main Apr 8, 2024
76 checks passed
@nigelgbanks nigelgbanks deleted the realip branch April 8, 2024 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants