nginx后端apache access_log的外网ip问题

 

=================== with-http_realip_module模块

 

./configure \

      --user=www \
      --group=www \
      --prefix=/usr/local/nginx \
      --with-http_stub_status_module \
      --add-module=../ngx_devel_kit \
      --add-module=../lua-nginx-module \
      --add-module=../drizzle-nginx-module \
      --add-module=../rds-json-nginx-module \
      --add-module=../headers-more-nginx-module \
      --add-module=../redis2-nginx-module \
      --add-module=../set-misc-nginx-module \
      --add-module=../ngx_http_upstream_keepalive \
      --with-http_realip_module

 

===============vim /usr/local/webserver/nginx/conf/proxy_params

 

proxy_set_header        Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header HTTP_CLIENT_IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For $remote_addr;

 

 

#chown www:www /usr/local/webserver/nginx/conf/proxy_params

 

============vim /usr/local/webserver/nginx/conf/nginx.conf

 

 

location / {
              proxy_pass      http://mysvsr ;
              proxy_redirect          off;
              include proxy_params;
              client_max_body_size    10m;
              client_body_buffer_size 128k;
              proxy_connect_timeout  90;
              proxy_send_timeout      90;
              proxy_read_timeout      90;
              proxy_buffer_size      4k;
              proxy_buffers          4 32k;
              proxy_busy_buffers_size 64k;
              proxy_temp_file_write_size 64k;
        }

 

 

 

 

 ===============vim /usr/local/webserver/apache2/conf/httpd.conf

 过滤js,gif等url

 

 
<IfModule log_config_module>
    SetEnvIf Remote_Host "(.)" realip=$1
    SetEnvIf X-Forwarded-For ^(.*) realip=$1
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    #LogFormat "%h %l %u %t \"%r\" %>s %b" common
    LogFormat "%t %{realip}e %>s %D %b \"%r\" %P \"%{Referer}i\" \"%{User-Agent}i\"" combined_bc

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

     #CustomLog "logs/access_log" common
    SetEnvIf Request_URI (.png$|.gif$|.jpg$|.swf$|.js$|.vbs$|.css$) log-ignore
    #CustomLog "logs/access_log" combined_bc
    CustomLog "|/usr/local/webserver/apache2/bin/rotatelogs /usr/local/webserver/apache2/logs/access_log.%Y%m%d 86400 480" combined_bc env=!log-ignore
        #CustomLog "logs/access_log" combined
</IfModule>

你可能感兴趣的:(apache,nginx,css,vim,Access)