nginx 安裝realip模塊


網站部署了流量代理服務(例如Web應用防火牆、DDoS高防、CDN)后,

源站服務器可以通過解析回源請求中的X-Forwarded-For記錄,獲取客戶端的真實IP。

 

1,查看原來nginx的安裝模塊

./nginx  -V

 沒有安裝

2,重新編譯原來的nginx

cd /tmp/nginx-1.18.0

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --without-http-cache --with-http_ssl_module --with-http_realip_module

make
make install

./nginx -V

 安裝成功

3,添加nginx的realip配置

set_real_ip_from 47.101.16.64/27;
real_ip_header X-Forwarded-For;
real_ip_recursive on;

以及 nginx的日志格式在log_format中添加http_x_forwarded_for字段,替換默認的remote_address字段

4,重啟nginx

./nginx -s reload

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM