配置nginx.conf文件的时候,测试未通过,提示如下配置错误:
real_ip_header X-Forwarded-For;
需要重新编译 Nginx 加上 --with-http_realip_module 参数,切换到nginx的安装目录
./configure --sbin-path=/usr/local/nginx/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/usr/local/nginx/nginx.pid \
--with-http_ssl_module \
--with-pcre=/usr/local/pcre \
--with-zlib=/usr/local/zlib \
--with-openssl=/usr/local/openssl \
--with-http_realip_module
配置完成后,进行编译:
make && make install
./nginx -t
./nginx -s reload
20170220更新,对应http节中:
include mime.types;
set_real_ip_from 10.158.0.0/16;
real_ip_header X-Forwarded-For;
default_type application/octet-stream;