源192.168.1.148 apache的html
代理192.168.1.142nginx
訪問192.168.1.141web
配置代理142apache
Vi /etc/nginx/nginx.confapp
worker_processes 2;測試
events {網站
worker_connections 1024;代理
}rest
http {日誌
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name _;
location / {
proxy_pass http://192.168.1.148:80;
proxy_set_header X-Real-IP $remote_addr;
}
}
}
systemctl restart nginx.service
配置源148的日誌
vi /etc/httpd/conf/httpd.conf
196行左右
LogFormat "%{X-Real-IP}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
systemctl restart httpd.service
測試訪問142會看到148的網站
查看148日誌會看到訪問者是141
cat /var/log/httpd/access_log
*************************************************************************
nginx
在148中
vi /etc/nginx/nginx.conf
location / {
root /web;
index index.html index.htm;
set_real_ip_from 192.168.1.0/24;
proxy_set_header X-Real-IP $remote_addr;
}
142中同上。。。
查看148
cat /usr/local/nginx/logs/access.log