1

internet -> nginx -> apache-2.4

Remote_Addr 打印 127.1.1.0 而不是客户端 ip。我在 nginx 后面有 apache,其设置如下: nginx.conf:

location / {
        try_files $uri @apache;
        }

location @apache {
        internal;
        proxy_pass http://127.0.0.1:8080;
        include proxy.conf;
        }

location ~ .*\.(php|php5)?$  {
        proxy_pass http://127.0.0.1:8080;
        include proxy.conf;
        }

代理.conf:

proxy_connect_timeout 300s;
proxy_send_timeout 900;
proxy_read_timeout 900;
proxy_buffer_size 32k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_redirect off;
proxy_hide_header Vary;
proxy_set_header Accept-Encoding '';
proxy_set_header Referer $http_referer;
proxy_set_header Cookie $http_cookie;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

httpd.conf:

Listen 127.0.0.1:8080
Include conf/extra/httpd-remoteip.conf

httpd-remoteip.conf:

LoadModule remoteip_module modules/mod_remoteip.so
RemoteIPHeader X-Forwarded-For
RemoteIPInternalProxy 127.0.0.1
4

1 回答 1

2

sed -i "s@LogFormat \"%h %l@LogFormat \"%h %a %l@" /usr/local/apache/conf/httpd.conf

于 2013-12-24T09:22:44.150 回答