背景

因为网站使用的是阿里云ssl免费证书,签发一次有效期只有三个月(一年只能申请20张免费ssl证书)。在过期之前会收到阿里云的即将过期邮件。

操作

阿里云创建免费证书

数字证书管理服务管理控制台 - SSL 证书 (aliyun.com) 登录后申请免费证书

将证书下载后配置到web服务器(此处我使用的nginx)

image-20240504134020680

重启nginx

1
./nginx -s reload

NGINX配置

NGINX安装

1
2
3
4
5
6
7
8
9
10
11
12
13
wget http://nginx.org/download/nginx-1.13.0.tar.gz                  
tar -zxvf nginx-1.13.0.tar.gz
yum install gcc gcc-c++ ncurses-devel perl
yum install pcre pcre-devel
yum  install zlib gzip zlib-devel

./configure
make & make install
默认安装路径:/usr/local/nginx下面
cd /usr/local/nginx
cd sbin/
./nginx 启动nginx
ps -ef|grep nginx

NGINX配置文件:

Nginx服务器上安装SSL证书_nginx安装ssl模块-CSDN博客

Nginx或Tengine服务器配置SSL证书_数字证书管理服务(原SSL证书)(SSL Certificate)-阿里云帮助中心 (aliyun.com)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen 80;
server_name shuaifeihao.top;

#charset koi8-r;

#access_log logs/host.access.log main;
rewrite ^(.*)$ https://$host$1;
location / {
root /home/www/hexo;
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;
#}
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
server {
listen 443 ssl;
server_name shuaifeihao.top;

ssl_certificate cert/shuaifeihao.top.pem;
ssl_certificate_key cert/shuaifeihao.top.key;

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;

ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location / {
root /home/www/hexo;
index index.html index.htm;
}



}

}

本站由 卡卡龙 使用 Stellar 1.27.0 主题创建

本站访问量 次. 本文阅读量 次.