lanmp 架构真实IP传导

Posted on Posted in apache, nginx

nginx 配置

location / {
    proxy_pass https://Uip;
    proxy_set_header Host $host;
    #proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header X-Forward-For $remote_addr;
    proxy_set_header HTTP_X_FORWARDED_FOR $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_redirect default;
}

apache2.4

LoadModule remoteip_module /usr/lib/apache2/modules/mod_remoteip.so
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 192.168.1.100 # 这里填写nginx代理的IP,有多个就再加一行

修改apache的log,加上 %a

LogFormat "%v:%p %h %a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %a %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# 下面第二种
LogFormat "%{X-Real-Ip}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{X-Real-Ip}i %h %l %u %t \"%r\" %>s %b" common
LogFormat "%{X-Real-Ip}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
» 转载请注明来源:若我若鱼 » lanmp 架构真实IP传导

Leave a Reply

Your email address will not be published. Required fields are marked *

11 − five =