Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

326
Views
Is there a way to pass the correct remote address to Nginx in a Docker container

I have a Nginx webserver that I'm running from inside a docker container. The problem I am having is that all client IP addresses in the nginx access.log are 172.19.0.1, the container's gateway. I would like the IP addresses shown to nginx to be the real IP addresses of the clients.

I've tried a few solutions that I found, including

  1. Using Nginx's realip module
    set_real_ip_from 172.19.0.1;
    real_ip_header X-Real-IP;
    real_ip_recursive on;

which still logged the gateway ip

  1. Setting the ports to host networking mode, which was ineffectual because I'm on macOS, and it is only supported on Linux.

The dockerfile I'm using looks like this

version: "3"
services:
    nginx:
        container_name: nginx
        ports:
            - target: 80
              published: 80
            - target: 443
              published: 443
        volumes:
            # [my volumes]
        restart: unless-stopped
        image: nginx
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!