nginx环境搭建
wget https://nginx.org/download/nginx-1.21.6.tar.gz(下载nginx安装包)
tar -xvzf nginx-1.21.6.tar.gz(解压缩)
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel(下载依赖库和包)
./configure --prefix=/soft/nginx/
make && make install(编译并安装)
sbin/nginx -s reload -c conf/nginx.conf # 修改配置后平滑重启
nginx反向代理
upstream nginx_boot{
30s内检查心跳发送两次包,未回复就代表该机器宕机,请求分发权重比为1:2
server 192.168.0.000:8080 weight=100 max_fails=2 fail_timeout=30s;
server 192.168.0.000:8090 weight=200 max_fails=2 fail_timeout=30s;
这里的IP请配置成你WEB服务所在的机器IP
}
server {
location / {
root html;
配置一下index的地址,最后加上index.ftl。
index index.html index.htm index.jsp index.ftl;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
请求交给名为nginx_boot的upstream上
proxy_pass http://nginx_boot;
}
}