41
创建后端应用

以一套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

1.  server {

2.  listen 8080 default_server;

3.  server_name _;

4.  root /usr/share/nginx/html;

5.   

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

7.   

8.  location / {

9.  }

10.  

11. error_page 404 /404.html;

12. location = /40x.html {

13. }

14.  

15. error_page 500 502 503 504 /50x.html;

16. location = /50x.html {

17. }

18. }

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

systemctl start nginx

systemctl status nginx

image.png

确保能正常访问:

image.png

web-02:

yum install nginx -y

vim /etc/nginx/nginx.conf

1.  server {

2.  listen 8080 default_server;

3.  server_name _;

4.  root /usr/share/nginx/html;

5.   

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

7.   

8.  location / {

9.  }

10.  

11. error_page 404 /404.html;

12. location = /40x.html {

13. }

14.  

15. error_page 500 502 503 504 /50x.html;

16. location = /50x.html {

17. }

18. }

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

systemctl start nginx

systemctl status nginx

image.png

确保能正常访问:

image.png

2.开放防火墙访问权限

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

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

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

firewall-cmd --reload

配置完成!

 


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

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