赞
踩
- # 安装工具,默认情况下是已安装。
- [root@RockyLinux9 ~]# dnf install -y openssl
- [root@RockyLinux9 ~]# cd /usr/local/nginx/conf/
-
-
- # 创建自签名证书
- [root@RockyLinux9 conf]# openssl req -x509 -newkey rsa:2048 -keyout linuxjsz.com.key -out linuxjsz.com.crt -nodes -days 365
- [root@RockyLinux9 conf]# ls linuxjsz.com.*
- linuxjsz.com.crt linuxjsz.com.key
[root@RockyLinux9 conf]# nginx -V
- [root@RockyLinux9 conf]# vim nginx.conf
- # 启用http块中的HTTPS server段
- http {
-
-
- ...
-
- # HTTPS server
- server {
- listen 443 ssl;
- server_name linuxjsz.com;
-
- # 配置证书路径
- ssl_certificate /usr/local/nginx/conf/linuxjsz.com.crt;
- ssl_certificate_key /usr/local/nginx/conf/linuxjsz.com.key;
-
-
- ssl_session_cache shared:SSL:1m;
- ssl_session_timeout 5m;
-
-
- ssl_ciphers HIGH:!aNULL:!MD5;
- ssl_prefer_server_ciphers on;
-
-
- location / {
- root html;
- index index.html index.htm;
- }
- }
- }
[root@RockyLinux9 conf]# nginx -s reload
- [root@RockyLinux9 conf]# vim nginx.conf
- http {
-
-
- server {
- listen 80;
- server_name linuxjsz.com;
- # 添加如下语句
- return 301 https://$host$request_uri;
- }
-
- # HTTPS server
- ...
- }
[root@RockyLinux9 conf]# nginx -s reload
- # 语法
- ssl_buffer_size size;
- # 默认值
- ssl_buffer_size 16k;
- # 语法
- ssl_certificate file;
- # 示例
- ssl_certificate example.com.rsa.crt;
- # 语法
- ssl_certificate_key file;
- # 示例
- ssl_certificate_key example.com.rsa.key;
- # 语法
- ssl_ciphers ciphers;
- # 默认值
- ssl_ciphers HIGH:!aNULL:!MD5;
- # 语法
- ssl_protocols [SSLv2] [SSLv3] [TLSv1] [TLSv1.1] [TLSv1.2] [TLSv1.3];
- # 默认值
- ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
- # 语法
- ssl_prefer_server_ciphers on | off;
- # 示例
- ssl_prefer_server_ciphers off;
- # 语法
- ssl_session_cache off | none | [builtin[:size]] [shared:name:size];
- # 默认值
- ssl_session_cache none;
- # 示例
- ssl_session_cache shared:SSL:10m;
- # 语法
- ssl_dhparam file;
- # 默认值
- ssl_dhparam /path/to/dhparam.pem;
- # 语法
- ssl_session_timeout time;
- # 默认值
- ssl_session_timeout 5m;
了解更多,请访问官方说明:
http://nginx.org/en/docs/http/ngx_http_ssl_module.html
分享、在看与点赞
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。