恒星手记

  1. 首页
  2. 杂记
  3. 正文

网站配置SSL(二、Nginx证书配置)

2025年11月1日 50点热度 0人点赞 0条评论

SSL 证书控制台 中选择需要安装的证书并单击下载

下载并解压后将stellardiary.site_bundle.crt和stellardiary.site.key上传至/etc/nginx/conf.d/ssl目录下

编辑/etc/nginx/conf.d/default.conf如下

server {
    #监听端口
    listen       80;
    listen 443 ssl;
    #根目录地址
    #root   /usr/share/nginx/html;
    root   /usr/share/nginx/html/wordpress;
    #域名
    #server_name  localhost;
    server_name  www.stellardiary.site;
    #证书文件的绝对路径
    ssl_certificate /etc/nginx/conf.d/ssl/stellardiary.site_bundle.crt;
    #私钥文件的绝对路径
    ssl_certificate_key /etc/nginx/conf.d/ssl/stellardiary.site.key;
    ssl_session_timeout 5m;
    #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    #请按照以下协议配置
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    #access_log  /var/log/nginx/host.access.log  main;
    location / {
index index.php 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   /usr/share/nginx/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$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
fastcgi_param  SCRIPT_FILENAME  $document_root$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;
    #}
}
#server {
#    listen 80;
#    #请填写绑定证书的域名
#    server_name www.stellardiary.site;
#    #把http的域名请求转成https
#    return 301 https://$host$request_uri;
#}

通过执行以下命令验证配置文件问题

nginx -t

通过执行以下命令重载 Nginx
nginx -s reload
重载成功,即可使用域名进行访问,如下图所示即为ssl配置完成
标签: 网站配置SSL
最后更新:2025年11月1日

数字

各位大哥大姐多多关照

点赞
< 上一篇

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

归档

  • 2025 年 11 月
  • 2025 年 10 月
  • 2025 年 9 月
  • 2025 年 8 月
  • 2025 年 7 月
  • 2025 年 6 月

分类

  • wordpress
  • zabbix
  • 服务器
  • 杂记

COPYRIGHT © 2025 恒星手记. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

粤ICP备2025416422号-1