背景

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

操作

阿里云创建免费证书

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

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

image-20240504134020680

重启nginx

./nginx -s reload

NGINX配置

NGINX安装

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)


#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.33.1主题创建

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