WHCSRL 技术网

用户画像数据埋点demo(网站用户行为日志采集和后台日志nginx服务器搭建)

通过浏览器访问httpd的index.html页面,index.html中js有数据埋点,埋到nginx,nginx里面就一个ma.js,ma.js中伪造的图片gif,通过图片gif绕过跨域



http://192.168.20.4/

yum -y install httpd
systemctl enable httpd
systemctl status firewalld
systemctl restart firewalld
firewall-cmd --list-ports
firewall-cmd --add-port=80/tcp --permanent --zone=public
firewall-cmd --reload

wget http://210.22.22.150:3731/mirrors/software/BigData/log-server/index.html.m -P /var/www/html/
mv /var/www/html/index.html.m /var/www/html/index.html

systemctl status httpd
systemctl restart httpd
ps -ef|grep httpd
curl 192.168.20.4



http://192.168.20.3/

yum install -y wget gcc perl pcre-devel openssl openssl-devel
mkdir -p /opt/software
wget http://210.22.22.150:3731/mirrors/software/BigData/log-server/LuaJIT-2.0.5.tar.gz -P /opt/software/
wget http://210.22.22.150:3731/mirrors/software/BigData/log-server/echo-nginx-module-0.58.tar.gz -P /opt/software/
wget http://210.22.22.150:3731/mirrors/software/BigData/log-server/lua-nginx-module-0.10.0.tar.gz -P /opt/software/
wget http://210.22.22.150:3731/mirrors/software/BigData/log-server/nginx-1.8.1.tar.gz -P /opt/software/
wget http://210.22.22.150:3731/mirrors/software/BigData/log-server/ngx_devel_kit-0.2.19.tar.gz -P /opt/software/
wget http://210.22.22.150:3731/mirrors/software/BigData/log-server/openresty-1.9.7.3.tar.gz -P /opt/software/
wget http://210.22.22.150:3731/mirrors/software/BigData/log-server/set-misc-nginx-module-0.29.tar.gz -P /opt/software/

tar -zxf /opt/software/LuaJIT-2.0.5.tar.gz -C /usr/local/src/
cd /usr/local/src/LuaJIT-2.0.5/
make -j 4 && make install -j 4 PREFIX=/usr/local/luajit
echo -e “ # lugjit_env” >> /etc/profile &&
echo -e “export LUAJIT_LIB=/usr/local/luajit/lib” >> /etc/profile &&
echo -e “export LUAJIT_INC=/usr/local/luajit/include/luajit-2.0” >> /etc/profile
source /etc/profile

mkdir -p /usr/local/nginx/modules
tar -zxf /opt/software/echo-nginx-module-0.58.tar.gz -C /usr/local/nginx/modules
tar -zxf /opt/software/lua-nginx-module-0.10.0.tar.gz -C /usr/local/nginx/modules
tar -zxf /opt/software/ngx_devel_kit-0.2.19.tar.gz -C /usr/local/nginx/modules
tar -zxf /opt/software/set-misc-nginx-module-0.29.tar.gz -C /usr/local/nginx/modules

tar -zxf /opt/software/openresty-1.9.7.3.tar.gz -C /usr/local/src/
cd /usr/local/src/openresty-1.9.7.3/
./configure --prefix=/usr/local/openresty --with-luajit && make -j 4 && make install -j 4

tar -zxf /opt/software/nginx-1.8.1.tar.gz -C /usr/local/src/
cd /usr/local/src/nginx-1.8.1/
./configure --prefix=/usr/local/nginx
–with-ld-opt="-Wl,-rpath,/usr/local/luajit/lib"
–add-module=/usr/local/nginx/modules/ngx_devel_kit-0.2.19
–add-module=/usr/local/nginx/modules/lua-nginx-module-0.10.0
–add-module=/usr/local/nginx/modules/set-misc-nginx-module-0.29
–add-module=/usr/local/nginx/modules/echo-nginx-module-0.58
make -j 4 && make install -j 4

systemctl status firewalld
systemctl restart firewalld
firewall-cmd --list-ports
firewall-cmd --add-port=80/tcp --permanent --zone=public
firewall-cmd --reload
firewall-cmd --list-ports

wget http://210.22.22.150:3731/mirrors/software/BigData/log-server/ma.js -P /usr/local/nginx/html/

mv /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak

wget http://210.22.22.150:3731/mirrors/software/BigData/log-server/nginx.conf -P /usr/local/nginx/conf/

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

ps -ef|grep nginx

tail -f logs/user_defined.log


参考:

https://zaomianbao.com/blog/2018/07/04/5

推荐阅读