NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
Dragonish3600
V2EX  ›  NGINX

nginx 开启 set_real_ip_from 后,怎么同时显示用户和 CDN IP 呢

  •  
  •   Dragonish3600 · Jul 25, 2018 · 4162 views
    This topic created in 2854 days ago, the information mentioned may be changed or developed.

    今天看 log 突然相当这个问题,比如 cloudflare 建议如下配置

    set_real_ip_from 103.21.244.0/22;
    set_real_ip_from 103.22.200.0/22;
    ...
    real_ip_header X-Forwarded-For;
    
    ....
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    '$status $body_bytes_sent "$http_referer" '
    

    这样配置后,有一个问题,就是用户直接访问服务器 IP,和通过 CDN 访问,在 Log 里是无法区分的。有没有什么更好的办法在 Log 末尾追加 CDN IP 呢

    3 replies    2018-07-25 14:23:53 +08:00
    cydian
        1
    cydian  
       Jul 25, 2018 via Android
    白名单仅设置 CDN IP。
    timonwong
        2
    timonwong  
       Jul 25, 2018
    $realip_remote_addr
    Dragonish3600
        3
    Dragonish3600  
    OP
       Jul 25, 2018
    @timonwong 搞定!刚才看文档发现这个参数了。不过还是感谢下
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1276 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 23:36 · PVG 07:36 · LAX 16:36 · JFK 19:36
    ♥ Do have faith in what you're doing.