nginx 安装realIp模块

1,查看原来nginx的安装模块

./nginx -V

--prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module  --with-pcre=/usr/local/src/pcre-8.35 --add-module=/usr/local/src/nginx-sticky-module-ng

2,编译原来的nginx

cd /usr/local/src/nginx-1.16.1

./configure  --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-pcre=/usr/local/src/pcre-8.35 --add-module=/usr/local/src/nginx-sticky-module-ng

make

make install

3, 查看是否安装好模块

./nginx -V

--prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-pcre=/usr/local/src/pcre-8.35 --add-module=/usr/local/src/nginx-sticky-module-ng

 

4,增加nginx的realIP配置

set_real_ip_from 172.30.1.23;
set_real_ip_from 172.30.2.182;
real_ip_header X-Forwarded-For;
real_ip_recursive on;

这个的前提是nginx的日志格式如下

log_format my_log_format '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$upstream_addr" "$request_time"';

posted @ 2020-09-10 11:24  春江潮水连海平  阅读(1070)  评论(0编辑  收藏  举报