6

Zabbix5.2实战系列之如何开启Https(LAMP)

 3 years ago
source link: http://os.51cto.com/art/202101/641033.htm
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

zIJz6nV.png!mobile

虽然大部分使用Zabbix的用户是放在内网,但是该掌握的还是需要的,万一要用到了呢?关于SSL的好处在此篇文章不再赘述了。可以自行度娘了,不过如果ssl证书在服务器解密会损耗机器的资源,当然你的这个前端并不是大众访问,所以基本可以忽略不计了,正常情况是前端挂负载或者nginx做证书解密。

Vb2IBfz.png!mobile

正文

环境介绍

系统版本:CentOS 8.2

PHP版本:7.4

Mariadb版本:10.3

web服务:Apache

安装ssl的插件

dnf -y install mod_ssl 

u2YJnmz.png!mobile

创建密钥存放的目录

mkdir -p /kasar/ssl 
chmod 700 /kasar/ssl 

创建证书及密钥

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /kasar/ssl/kasar.key -out /kasar/ssl/kasar.crt 

iEBN3yv.png!mobile

创建证书

编辑SSL配置文件

编辑ssl.conf配置文件,修改如下图几处地方

vi /etc/httpd/conf.d/ssl.conf 

auq63if.png!mobile

修改根目录

3E3Ujee.png!mobile

调整证书及密钥路径

重启服务

systemctl restart httpd 

最终效果

MZRZ7r.png!mobile

最终效果

强制跳转

nqmANb7.png!mobile

既然启用了https,那么强制跳转也是必备选项

需要修改两处:

vim /etc/httpd/conf.d/zabbix.conf 

zYNjamU.png!mobile

将此处改为All

创建.htaccess文件实现跳转,添加如下内容到该文件,随后重启http服务,即可实现跳转,具体细节就不多提了,可以查阅apache官方文档,或自行度娘。

vi /usr/share/zabbix/.htaccess 
RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

实际生产效果

m2YVZra.png!mobile

blog.kasar.net.cn仅为演示

总结

LAMP的步骤相对较少,文章也比较简单,但是里面的内容理论还是挺多,需要各位下去自行研究,现在公网上的免费证书较多,但时长都不久,一般企业有泛域名的证书,也可以申请,但是做这个的必要性是不是很大,这就需要自己判断了,毕竟是一个内部的网站,而且用途单一,专业性强。那么最后还是那句话:路漫漫其修远兮,吾将上下而求索。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK