前端服务器:192.168.26.210
后端服务器:192.168.26.212,192.168.26.218
nginx和Apache安装略,可以直接YUM安装。
#nginx.conf配置文件
# The default server
#
upstream idc.jerry.com {
server 192.168.26.212:80;
server 192.168.26.218:80;
}
server {
listen 80 default_server;
server_name idc.jerry.com;
#charset koi8-r;
#access_log logs/host.access.log main;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
proxy_pass http://idc.jerry.com;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html; #设置成维护页面
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
刷新访问前端IP:192.168.26.210
后端服务器都挂掉时:返回服务器维护时间。
转载于:https://blog.51cto.com/jdonghong/1887598