xoxo419
V2EX  ›  问与答

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

  •  
  •   xoxo419 · Sep 13, 2018 · 7718 views
    This topic created in 2978 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
    precisi0nux
    Sep 13, 2018 via iPhone
    1
    X-Forwarded-For
    xoxo419
    xoxo419
    OP
    Sep 13, 2018
    2
    @precisi0nux 直接 nginx 配置? 我有测试过, 不行呢.
    sky101001
    sky101001
    Sep 13, 2018 via iPad
    3
    同 X-Forwarded-For,可以正确获取真实 ip
    xoxo419
    xoxo419
    OP
    Sep 13, 2018
    4
    @sky101001 只是改 Nginx 配置就行么 还需要做其他的配置?

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