https证书配置 (nginx 、apache)

本文介绍如何在freessl.cn申请免费SSL证书,并详细指导完成域名解析及使用KeyManager管理证书的过程。此外,还提供了Nginx环境下HTTPS服务的配置步骤,包括证书文件的存放位置与配置文件的具体设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

申请证书

网址:https://freessl.cn/

  1. 填写域名点击创建
  2. 按照生成的解析信息,去域名解析平台做解析
  3. 保存到KeyManager (pc应用程序,需要下载,会有提示下载)
  4. 在KeyManager导出域名证书文件,可以导出Nginx、Apache等各种类型的,按需导出。

Nginx环境配置

nginx安装目录如下
在这里插入图片描述

1.创建目录ssl 存放证书文件
在这里插入图片描述
2.配置文件,指向证书文件位置

# http 重定向到 https
server {
	listen       80;
	server_name songin.zhdingli.com www.zhdingli.com;
    if ($scheme != "https") {
            return 301 https://$host$request_uri;
    }
}

# HTTPS 服务
server {
    listen       443 ssl;

	#https安全证书配置
	ssl on;
    ssl_certificate      /etc/nginx/ssl/songin.zhdingli.com/cert.pem;
    ssl_certificate_key  /etc/nginx/ssl/songin.zhdingli.com/cert.key;
	
    ssl_session_cache    shared:SSL:1m;
    ssl_session_timeout  5m;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;
	
	#域名
    server_name  songin.zhdingli.com;
	
	#访问日志
	access_log /etc/nginx/logs/songin.zhdingli.com-ssl_access.log;
	error_log /etc/nginx/logs/songin.zhdingli.com-ssl_error.log warn;
	
	root /home/www/songin.zhdingli.com;
	
    location / {
        #root   html;
        index  index.html index.htm;
    }
	
	#error_page  404              /404.html;
	# redirect server error pages to the static page /50x.html
	error_page   500 502 503 504  /50x.html;
	location = /50x.html {
		root   html;
	}
	
	# proxy the PHP scripts to Apache listening on 127.0.0.1:80
	#
	#location ~ \.php$ {
	#    proxy_pass   http://127.0.0.1;
	#}

	# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
	#
	#location ~ \.php$ {
	#    root           html;
	#    fastcgi_pass   127.0.0.1:9000;
	#    fastcgi_index  index.php;
	#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
	#    include        fastcgi_params;
	#}

	# deny access to .htaccess files, if Apache's document root
	# concurs with nginx's one
	#
	#location ~ /\.ht {
	#    deny  all;
	#}

}

3.保存配置后,重启nginx

/etc/nginx/sbin/nginx -s reload
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值