报错集“nginx: [emerg] unknown directive "set_real_ip_from" in /usr/local/nginx/conf/nginx.conf:50 nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed”的报错解决方法
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed”的报错解决方法
报错描述
nginx: [emerg] unknown directive “set_real_ip_from” in /usr/local/nginx/conf/nginx.conf:50
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
问题描述
我在做一台nginx对应两台动态处理的服务Tomcat的时候,修改nginx配置文件出现如下报错
[root@localhost local]# nginx -t
nginx: [emerg] unknown directive "set_real_ip_from" in /usr/local/nginx/conf/nginx.conf:50
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
[root@localhost local]#
原因分析
因为nginx缺少了realip模块
解决方法
重新添加realip模块编译
--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
问题解决
[root@localhost nginx-1.15.9]# nginx -t
nginx: [warn] low address bits of 192.168.56.1/24 are meaningless in /usr/local/nginx/conf/nginx.conf:50
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful