通过Laravel中的apache反向代理获取Nuxt应用程序的真实用户ip

通过Laravel中的apache反向代理获取Nuxt应用程序的真实用户ip,laravel,apache,vue.js,nuxt.js,reverse-proxy,Laravel,Apache,Vue.js,Nuxt.js,Reverse Proxy,我使用Nuxtjs作为应用程序的前端,使用Laravel框架作为后端。 我在Apache Centos服务器上托管了我的应用程序。 在localhost:3000上运行pm2应用程序后,我无法在Laravel中获得用户的真实ip 我的Centos版本: Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-1127.10.1.el7.x86_64 Archi

我使用Nuxtjs作为应用程序的前端,使用Laravel框架作为后端。 我在Apache Centos服务器上托管了我的应用程序。 在localhost:3000上运行pm2应用程序后,我无法在Laravel中获得用户的真实ip

我的Centos版本:

Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-1127.10.1.el7.x86_64
Architecture: x86-64
我的Apache版本:

Server version: Apache/2.4.43 (Unix)
我的apache虚拟主机:

<VirtualHost MY_IP:80>
    UserDir public_html
    DocumentRoot /var/www/html
    ServerName example.com
    ProxyPreserveHost On
    RemoteIPHeader X-Forwarded-For
    RemoteIPProxiesHeader X-Forwarded-By
    <LocationMatch "/">
        allow from all
        Satisfy any
        AllowOverride All
        Require all granted
        ProxyPass http://localhost:3000/
        ProxyPassReverse http://localhost:3000/
    </LocationMatch>
</VirtualHost>
但是在这些步骤之后,当我使用
request()->ip()
request()->getClientIp()
在Laravel中,它为我提供了服务器ip。
如何在我的Laravel应用程序中获得真正的用户ip?

可能是您要查找的HTTP头变量的HTTP\u X\u转发

$_SERVER['HTTP_X_FORWARDED_FOR']

如果它不存在,Apache的mod_remoteip模块可以帮助此头变量
更多信息:

感谢@Mustafa的回复。但是$\u服务器变量中的索引没有
HTTP\u X\u FORWARDED\u我在我的应用程序中使用了与您相同的设置nuxt+laravel唯一的区别是nginx,所以我是nginx的家伙,但这有帮助吗?在我的apache web服务器中:
a2enmod:command not found
如果没有,请尝试使用sudo。我在sudo中使用了一些相关主题,但它说
command not found
。我列出了我的apache模块,我看到了这个
remoteip\u模块(静态)
$_SERVER['HTTP_X_FORWARDED_FOR']
 $_SERVER["HTTP_X_REAL_IP"]