57
创建后端应用

以一套web应用作为示例。

前提:已经创建好后两台云服务器。

准备环境:

后端服务器:web-01 centos7.2,8080端口

后端服务器:web-02 centos7.2,8080端口

1.安装好web服务

以nginx为例,rpm方式安装nginx,开放8080端口对外服务:

web-01:


yum install nginx -y


vim /etc/nginx/nginx.conf


server {

listen 8080 default_server;

server_name _;

root /usr/share/nginx/html;

include /etc/nginx/default.d/*.conf;

location / {

}

error_page 404 /404.html;

location = /40x.html {

}

error_page 500 502 503 504 /50x.html;

location = /50x.html {

}

}



echo “this is web-01” > /usr/share/nginx/html/index.html


systemctl start nginx


systemctl status nginx




1.png

确保能正常访问:

2.png

web-02:

yum install nginx -y

vim /etc/nginx/nginx.conf

server {
listen 8080 default_server;
server_name _;
root /usr/share/nginx/html;
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}error_page 500 502 503 504 /50x.html;location = /50x.html {}}

echo “this is web-02” > /usr/share/nginx/html/index.html

systemctl start nginx

systemctl status nginx

3.png

确保能正常访问:

4.png

2.开放防火墙访问权限

如果云服务器开启了防火墙,则需要开启负载均衡实例健康检查网络地址的防火墙访问权限健康检查网络地址

分别在web-01和web-02上:

firewall-cmd --add-rich-rule="rule family="ipv4" source address="负载均衡公网IP/32" accept" --permanent

firewall-cmd --reload

配置完成!


这条帮助是否解决了您的问题? 已解决 未解决

提交成功!非常感谢您的反馈,我们会继续努力做到更好! 很抱歉未能解决您的疑问。我们已收到您的反馈意见,同时会及时作出反馈处理!