欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

Centos6.8上httpd配置腾讯云SSL证书

发布时间:2024/1/17 65 豆豆
生活随笔 收集整理的这篇文章主要介绍了 Centos6.8上httpd配置腾讯云SSL证书 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

(1)先按装mod_ssl

yum -y install mod_ssl

 /etc/httpd/conf.d/下会有一个ssl.conf的文件,打开

a)检测本地证书配置是否正确

  主要是看下证书及密钥的位置
  SSLCertificateFile /etc/pki/tls/certs/localhost.crt
  SSLCertificateKeyFile /etc/pki/tls/private/localhost.key

  1)生成证书
   进入/etc/pki/tls/private,

rm -f localhost.key openssl genrsa 1024 > localhost.key #生成新的localhost.key 切换文件夹 cd ../certs rm -rf localhost.crt #删除原来的证书 openssl req -new -x509 -days 365 -key ../private/localhost.key -out localhost.crt #生产新文件夹

填写需要填写的信息,生产证书。

说明:localhost.crt这样的名子,是因为在ssl.conf是这样指定的,这两个地方要同步

重启apache,配置结束
现在就可以通过https访问网站

打开端口443:

iptables -I INPUT -p TCP –dport 443 -j ACCEPT 或 iptables -I INPUT -p TCP –dport 443 -j ACCEPT

注意:阿里云服务商要配置开放https需要使用的443端口的入规则

Apache下设置自动将http跳转到https方法:

首先在网站根目录下创建.htaccess文件,并写入

RewriteEngine on RewriteBase / RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

或者在httpd.conf中启用重写,启动重定向,使用用户HTTP访问自动重定向为HTTPS,直接在http.conf最后配置即可,在httpd.conf文件尾加入如下内容

RewriteEngine on RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^/?(.*)$ https://%{SERVER_NAME}/$1 [L,R]

现在在浏览器中访问,会提示不安全的链接,接下来引入腾讯云的ssl证书

(2)配置ssl.conf ,贴上源码

      1.上传证书到服务器/etc/httpd/conf/cert/目录下LoadModule ssl_module modules/mod_ssl.soListen 443

      2.ssl.conf配置如下:

SSLPassPhraseDialog builtin SSLSessionCache shmcb:/var/cache/mod_ssl/scache(512000) SSLSessionCacheTimeout 300 SSLMutex default SSLRandomSeed startup file:/dev/urandom 256 SSLRandomSeed connect builtin SSLCryptoDevice builtin SSLProtocol all -SSLv2 -SSLv3 SSLHonorCipherOrder on SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW:!RC4:<VirtualHost _default_:443> # 必须有一个虚拟主机,这样才可以使用跳转功能和使用443端口访问 DocumentRoot "/home/store/www" ServerName www.zyin8.com:443 #
DirectoryIndex index.html index.php  index.html.var
ErrorLog logs/ssl_error_log TransferLog logs/ssl_access_log LogLevel warn SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW:!RC4:
SSLCertificateFile /etc/httpd/conf/cert/2_www.zyin8.com.crt #证书 SSLCertificateKeyFile /etc/httpd/conf/cert/3_www.zyin8.com.key #秘钥
SSLCertificateChainFile /etc/httpd/conf/cert/1_root_bundle.crt #链接
</VirtualHost>

        3.service httpd restart

      在浏览器输入https://域名 或者 域名:443,如果两个能正常访问,表示https已经配置成功。

      在浏览器输入 域名,如果能够正常跳转到https连接上,那说明跳转功能正常。

转载于:https://www.cnblogs.com/shione/p/7266146.html

总结

以上是生活随笔为你收集整理的Centos6.8上httpd配置腾讯云SSL证书的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。