V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
xoxo419
V2EX  ›  问与答

docker 如何让 Nginx 获取到访问者 IP?

  •  
  •   xoxo419 · Sep 13, 2018 · 7350 views
    This topic created in 2789 days ago, the information mentioned may be changed or developed.

    现在有没有简单的方式通过配置下就可以的方法呢?

    通过 Google 查到的相关问题

    Document how to get real remote client ip for service running in container

    nginx 获取客户端 IP 实现 根据配置了但无法获取到真实 IP

    network_mode-docker 网络连接方式

    nginx cannot get to client IP

    Supplement 1  ·  Sep 15, 2018
    MAC- 只能获取容器的 IP. 但是 Linux 上可以获取到客户端的真实 IP [关于问题相关的资料]( http://www.majianwei.com/archives/7909)
    8 replies    2020-03-04 17:50:30 +08:00
    precisi0nux
        1
    precisi0nux  
       Sep 13, 2018 via iPhone
    X-Forwarded-For
    xoxo419
        2
    xoxo419  
    OP
       Sep 13, 2018
    @precisi0nux 直接 nginx 配置? 我有测试过, 不行呢.
    sky101001
        3
    sky101001  
       Sep 13, 2018 via iPad
    同 X-Forwarded-For,可以正确获取真实 ip
    xoxo419
        4
    xoxo419  
    OP
       Sep 13, 2018
    @sky101001 只是改 Nginx 配置就行么 还需要做其他的配置?

    https://github.com/docker/for-mac/issues/180
    autotesting
        5
    autotesting  
       Apr 15, 2019
    @xoxo419 取到真实 ip 现在好像还是不行呢,你当时怎么解决的呀?
    xoxo419
        6
    xoxo419  
    OP
       Apr 16, 2019
    @autotesting 服务器放在外网的就可以、
    autotesting
        7
    autotesting  
       Apr 16, 2019
    @xoxo419 啥意思,啥叫服务器放在外网,是 docker 部署在 linux 上的意思吗?
    hzw1199
        8
    hzw1199  
       Mar 4, 2020
    Nginx 如果部署成一个容器,而且网络不是 host 模式,至少现在来看是不可能获取到真实 ip 的。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   825 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 20:13 · PVG 04:13 · LAX 13:13 · JFK 16:13
    ♥ Do have faith in what you're doing.