安装与web服务器一致
Nginx反向代理模块:http://nginx.org/en/docs/
1、ngx_upsream module
2、ngx_http_proxy module
nginx.conf配置在http内
cat >nginx.conf<< eof
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
log_format main '\$remote_addr - \$remote_user [\$time_local] "\$request" '
'\$status \$body_bytes_sent "\$http_referer" '
'"\$http_user_agent" "\$http_x_forwarded_for"';
upstream server_pools{
server 192.168.137.8:80;
server 192.168.137.9:80;
}
include /application/nginx/conf/extra/*.conf;
}
eof
配置反向代理
mkdir -p /application/nginx/conf/extra &&\
touch /application/nginx/conf/extra/lb.conf &&\
cat > /application/nginx/conf/extra/lb.conf << eof
server {
listen 192.168.137.4:80;
server_name bbs.test.com;
location / {
proxy_pass http://server_pools;
proxy_set_header Host \$host;
proxy_set_header X-Real-Ip \$remote_addr;
proxy_set_header X-Forwarded-For \$remote_addr;
}
}
eof
nginx里记录X-Forwarder-For真实来源地址
apache需要在日志格式里添加\"${X-Forwarded-For}\"
利用VIP是为了方便迁移切换,业务尽量用虚拟IP
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。