【运维知识进阶篇】集群架构-HTTPS证书详解(下)

简介: 【运维知识进阶篇】集群架构-HTTPS证书详解(下)

Nginx集群实现证书

1、准备LB01(10.0.0.5、172.16.1.5)做负载均衡,Web02(10.0.0.8、172.16.1.8)、Web03(10.0.0.9、172.16.1.9)两台服务器

2、配置Web02、Web03服务器监听80端口

1. [root@Web02 ~]# cat /etc/nginx/conf.d/ssl.conf
2. server {
3.         listen 80;
4.         server_name ssl.koten.com;
5. 
6.         location / {
7.                 root /code/ssl;
8.                 index index.html;
9.         }
10. }
11. [root@Web02 ~]# systemctl restart nginx
12. 
13. [root@Web03 ~]# cat /etc/nginx/conf.d/ssl.conf
14. server {
15.         listen 80;
16.         server_name ssl.koten.com;
17. 
18.         location / {
19.                 root /code/ssl;
20.                 index index.html;
21.         }
22. }
23. [root@Web03 ~]# systemctl restart nginx

3、拷贝证书到LB服务器

1. [root@LB01 ~]# scp -rp 172.16.1.7:/etc/nginx/ssl_key /etc/nginx/
2. The authenticity of host '172.16.1.7 (172.16.1.7)' can't be established.
3. ECDSA key fingerprint is SHA256:zQvI/tCFYssR7l6cr90EtaIA93FXJp8FmUhGtkZshlA.
4. ECDSA key fingerprint is MD5:0b:a1:ee:d2:75:92:1a:62:05:63:5e:d1:e8:42:13:84.
5. Are you sure you want to continue connecting (yes/no)? yes
6. Warning: Permanently added '172.16.1.7' (ECDSA) to the list of known hosts.
7. root@172.16.1.7's password: 
8. server.key       100% 1704   906.5KB/s   00:00    
9. server.crt       100% 1411     1.0MB/s   00:00

4、配置LB01的Nginx配置文件

1. [root@LB01 ~]# cat /etc/nginx/conf.d/proxy_ssl.conf 
2. upstream website {
3.         server 172.16.1.8:80;
4.         server 172.16.1.9:80;
5. }
6. 
7. server {
8.         listen 443 ssl;
9.         server_name ssl.koten.com;
10.         ssl_certificate   ssl_key/server.crt;
11.         ssl_certificate_key  ssl_key/server.key;
12.         location / {
13.             proxy_pass http://website;
14.             proxy_set_header Host $http_host;
15.         }
16. }
17. 
18. server {
19.         listen 80;
20.         server_name ssl.koten.com;
21. return 302 https://$server_name$request_uri;
22. }
23. [root@LB01 ~]# systemctl restart nginx

5、浏览器访问

 

真实业务实现HTTPS证书

1、配置LB01中的wordpress和wecenter的配置

1. [root@LB01 ~]# cat /etc/nginx/conf.d/proxy_ssl.conf 
2. upstream webs {
3.         server 172.16.1.7:80;
4.         server 172.16.1.8:80;
5. }
6. 
7. #用户的http请求跳转至https
8. server {
9.         listen 80;
10.         server_name blog.koten.com;
11. return 302 https://$server_name$request_uri;
12. }
13. 
14. server {
15.         listen 80;
16.         server_name wecenter.koten.com;
17. return 302 https://$server_name$request_uri;
18. }   
19. 
20. server {
21.         listen 443 ssl;
22.         server_name blog.koten.com;
23.         ssl_certificate   ssl_key/server.crt;
24.         ssl_certificate_key  ssl_key/server.key;
25.         location / {
26.                 proxy_pass http://webs;
27.                 include proxy_params;
28.         }
29. }
30. 
31. server {
32.         listen 443 ssl;
33.         server_name wecenter.koten.com;
34.         ssl_certificate   ssl_key/server.crt;
35.         ssl_certificate_key  ssl_key/server.key;
36.         location / {
37.                 proxy_pass http://webs;
38.                 include proxy_params;
39.         }       
40. }
41. [root@LB01 ~]# nginx -t
42. nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
43. nginx: configuration file /etc/nginx/nginx.conf test is successful
44. [root@LB01 ~]# nginx -s reload

2、浏览器访问

发现均出现排版错误的情况,这是因为PHP对https不适配。

3、修正排版问题

需要在Web01和Web02的Wecenter和WordPress配置文件里添加如下配置,并重启Nginx

1. #告诉PHP我前置的负载使用的是https协议                
2. fastcgi_param HTTPS on;

例如Web01的WordPress配置文件

1. [root@Web01 wecenter]# cat /etc/nginx/conf.d/wordpress.conf 
2. server {
3.  listen 80;
4.  server_name blog.koten.com;
5.  root /code/wordpress;
6.  index index.php index.html index.htm;
7. 
8.  location ~\.php$ {
9.    root /code/wordpress;
10.     fastcgi_pass 127.0.0.1:9000;
11.     fastcgi_index index.php;
12.     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
13.         fastcgi_param HTTPS on;
14.     include fastcgi_params;
15.   }
16. }
17. [root@Web01 wecenter]#

4、再次访问发现恢复

5、phpmyadmin配置文件与问题

1. [root@LB01 ~]# cat /etc/nginx/conf.d/proxy_php.conf 
2. upstream web {
3.         server 172.16.1.7:80;
4.         server 172.16.1.8:80;
5. }
6. 
7. server {
8.         listen 80;
9.         server_name php.koten.com;
10. return 302 https://$server_name$request_uri;
11. }
12. 
13. server {
14.         listen 443 ssl;
15.         ssl_certificate   ssl_key/server.crt;
16.         ssl_certificate_key  ssl_key/server.key;
17.         server_name php.koten.com;
18.         location / {
19.             proxy_pass http://web;
20.             include proxy_params;
21.         }
22. }
23. [root@LB01 ~]# systemctl restart nginx

6、解决phpmyadmin问题

在Web01和Web02的phpmyadmin配置文件上增加如下配置:

fastcgi_param HTTPS on;

恢复正常!

目录
相关文章
|
机器学习/深度学习 人工智能 运维
云架构不是养祖宗,智能运维教你省心又省钱
云架构不是养祖宗,智能运维教你省心又省钱
368 2
|
数据采集 运维 数据可视化
AR 运维系统与 MES、EMA、IoT 系统的融合架构与实践
AR运维系统融合IoT、EMA、MES数据,构建“感知-分析-决策-执行”闭环。通过AR终端实现设备数据可视化,实时呈现温度、工单等信息,提升运维效率与生产可靠性。(238字)
|
负载均衡 算法 关系型数据库
大数据大厂之MySQL数据库课程设计:揭秘MySQL集群架构负载均衡核心算法:从理论到Java代码实战,让你的数据库性能飙升!
本文聚焦 MySQL 集群架构中的负载均衡算法,阐述其重要性。详细介绍轮询、加权轮询、最少连接、加权最少连接、随机、源地址哈希等常用算法,分析各自优缺点及适用场景。并提供 Java 语言代码实现示例,助力直观理解。文章结构清晰,语言通俗易懂,对理解和应用负载均衡算法具有实用价值和参考价值。
大数据大厂之MySQL数据库课程设计:揭秘MySQL集群架构负载均衡核心算法:从理论到Java代码实战,让你的数据库性能飙升!
|
消息中间件 负载均衡 中间件
⚡ 构建真正的高性能即时通讯服务:基于 Netty 集群的架构设计与实现
本文介绍了如何基于 Netty 构建分布式即时通讯集群。随着用户量增长,单体架构面临性能瓶颈,文章对比了三种集群方案:Nginx 负载均衡、注册中心服务发现与基于 ZooKeeper 的消息路由架构。最终选择第三种方案,通过 ZooKeeper 实现服务注册发现与消息路由,并结合 RabbitMQ 支持跨服务器消息广播。文中还详细讲解了 ZooKeeper 搭建、Netty 集群改造、动态端口分配、服务注册、负载均衡及消息广播的实现,构建了一个高可用、可水平扩展的即时通讯系统。
1515 0
|
存储 监控 NoSQL
Redis高可用架构全解析:从主从复制到集群方案
Redis高可用确保服务持续稳定,避免单点故障导致数据丢失或业务中断。通过主从复制实现数据冗余,哨兵模式支持自动故障转移,Cluster集群则提供分布式数据分片与水平扩展,三者层层递进,保障读写分离、容灾切换与大规模数据存储,构建高性能、高可靠的Redis架构体系。
|
运维 监控 Cloud Native
从“守机器”到“写策略”——云原生架构把运维逼成了架构师
从“守机器”到“写策略”——云原生架构把运维逼成了架构师
488 1
求助!怎么上传第三方HTTPS证书?为什么我上传lets encrypt的证书显示私钥格式异常?
用户上传证书时遇到问题,提示格式异常,已尝试转换RSA格式仍未解决。
|
人工智能 安全 算法
HTTPS 的「秘钥交换 + 证书校验」全流程
HTTPS 通过“证书如身份证、密钥交换如临时暗号”的握手流程,实现身份认证与数据加密双重保障,确保通信安全可靠。
1591 0
|
安全 网络协议 Linux
Linux网络应用层协议展示:HTTP与HTTPS
此外,必须注意,从HTTP迁移到HTTPS是一项重要且必要的任务,因为这不仅关乎用户信息的安全,也有利于你的网站评级和粉丝的信心。在网络世界中,信息的安全就是一切,选择HTTPS,让您的网站更加安全,使您的用户满意,也使您感到满意。
623 19
|
网络安全 开发者
如何解决HTTPS协议在WordPress升级后对网站不兼容的问题
以上就是解决WordPress升级后HTTPS协议对网站的不兼容问题的方法。希望能把这个棘手的问题看成是学校的管理问题一样来应对,将复杂的技术问题变得更加有趣和形象,并寻觅出解决问题的方式。希望你的网站能在新的学期得到更好的发展!
499 19

热门文章

最新文章