欧卡2中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

需要三步,才能开始

只需两步,慢速开始

欧卡2入门方向盘选莱仕达V9莱仕达折叠便携游戏方向盘支架欢迎地图Mod入驻
查看: 834|回复: 3
收起左侧

[Linux] php+nginx容器获取客户端ip

[复制链接]
元芳 发表于 2022-9-26 14:49 | 显示全部楼层 |阅读模式

php+nginx容器,获取客户端ip的设置:

    location ~ .php(/|$) {
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO             $fastcgi_script_name;
        set $realip $remote_addr;
        if ($http_x_forwarded_for ~ "^(\d+\.\d+\.\d+\.\d+)") {
            set $realip $1;
        }
        fastcgi_param REMOTE_ADDR $realip;
    } 
知行 发表于 2023-3-28 23:22 | 显示全部楼层
此贴只实现了PHP中获取真实IP,用于wp之类程序记录评论者IP,Nginx日志中显示的还是容器IP  172.17.0.1
回复 打印

使用道具 举报

知行 发表于 2023-4-10 08:58 | 显示全部楼层
测试
echo "hello"
回复 打印

使用道具 举报

知行 发表于 2023-4-25 19:19 | 显示全部楼层

test

回复 打印

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

联系我们|手机版|欧卡2中国 ( 湘ICP备11020288号-1 )

GMT+8, 2024-3-29 04:50 , Processed in 0.040112 second(s), 11 queries , Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表