开启https

打开 apache 安装目录下 conf 目录中的 httpd.conf 文件,找到以下内容并去掉“#”。

#LoadModule ssl_module modules/mod_ssl.so (如果找不到请确认是否编译过 openssl 插件)
#LoadModule rewrite_module modules/mod_rewrite.so
#Include conf/extra/httpd-ssl.conf(删除行首的配置语句注释符号“#”,保存后退出)

打开 apache 安装目录下 conf/extra/httpd-ssl.conf 文件 (也可能是conf.d/ssl.conf,与操作系统及安装方式有关), 在配置文件中查找以下配置语句:

# 添加 SSL 协议支持协议,去掉不安全的协议
SSLProtocol all -SSLv2 -SSLv3
# 修改加密套件如下
SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
SSLHonorCipherOrder on
# 证书公钥配置
SSLCertificateFile "/csr/2714481_www.example.cn_public.crt"
# 证书私钥配置
SSLCertificateKeyFile "/csr/2714481_www.example.cn.key"
# 证书链配置,如果该属性开头有 '#'字符,请删除掉
SSLCertificateChainFile "/csr/2714481_www.example.cn_chain.crt"
重启 Apache。

apachectl -k stop
apachectl -k start

nginx
打开 Nginx 安装目录下 conf 目录中的 nginx.conf 文件,找到:

# HTTPS server
# #server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;
# location / {
#
#
#}
#}

将其修改为 (以下属性中ssl开头的属性与证书配置有直接关系,其它属性请结合自己的实际情况复制或调整) :

server {
listen 443;
server_name localhost;
ssl on;
root html;
index index.html index.htm;
ssl_certificate cert/a.pem;
ssl_certificate_key cert/a.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
}
保存退出。

重启 Nginx。

<VirtualHost *:80>
ServerAdmin example.cn
DocumentRoot "/usr/local/httpd/htdocs/bbs/"
ServerName example.cn
#ServerAlias example.cn
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R,L]
ErrorLog "/var/log/httpd/error_log"
CustomLog "/var/log/httpd/access_log" common
</VirtualHost>

<VirtualHost *:443>
SSLEngine On
SSLCertificateKeyFile "/csr/2714481_www.example.cn.key"
SSLCertificateChainFile "/csr/2714481_www.example.cn_chain.crt"
SSLCertificateFile "/csr/2714481_www.example.cn_public.crt"
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/local/httpd/htdocs/bbs/"
ServerName www.example.cn
ErrorLog "/var/log/httpd/error_log"
CustomLog "/var/log/httpd/access_log" common
</VirtualHost>

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注