报错:nginx: [emerg] unknown directive “set_real_ip_from“ in /usr/local/nginx/conf/nginx.conf:50

报错项

在开启nginx获取客户端IP地址模块功能的时候,启动报错

nginx: [emerg] unknown directive "set_real_ip_from" in /usr/local/nginx/conf/nginx.conf:50

报错原因

nginx在编译安装的时候没有开启 --with-http_realip_module 该模块功能(获取客户端IP地址)

解决方案

重新编译安装ngixn,./configure 配置是开启 --with-http_realip_module 模块功能

./configure \
--prefix=/usr/local/nginx \
--user=nginx \
--group=nginx \
--with-http_stub_status_module \
--with-http_realip_module
make && make install