首页 > 系统相关 >NGINX 配置 SSL 双向认证

NGINX 配置 SSL 双向认证

时间:2023-01-05 10:00:44浏览次数:43  
标签:crt ssl openssl 认证 NGINX client key SSL server

NGINX 配置 SSL 双向认证 1.1. 生成一个 CA 私钥: ca.key openssl genrsa -out ca.key 4096 1.2. 生成一个 CA 的数字证书: ca.crt(Common Name 随意填写;其它可以填”.”) openssl req -new -x509 -days 3650 -key ca.key -out ca.crt -config D:/software/nginx-1.15.8/conf/ssl/openssl.cnf 2.1. 生成 server 端的私钥: server.key openssl genrsa -out server.key 4096 2.2. 生成 server 端数字证书请求: server.csr(Common Name填写访问服务器时域名,配置nginx时用到,不能与CA的相同 其它填写”.”) openssl req -new -key server.key -out server.csr -config D:/software/nginx-1.15.8/conf/ssl/openssl.cnf 2.3. 用 CA 私钥签发 server 的数字证书: server.crt openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 3650 3.1. 生成客户端的私钥与证书: client.key openssl genrsa -out client.key 4096 3.2. 生成 client 端数字证书请求: client.csr(Common Name填写访问服务器时域名,配置nginx时用到,不能与CA的相同 其它填写”.”) openssl req -new -key client.key -out client.csr -config D:/software/nginx-1.15.8/conf/ssl/openssl.cnf 3.3. 用 CA 私钥签发 client 的数字证书: client.crt openssl x509 -req -in client.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out client.crt -days 3650 3.4. 生成p12格式客户端证书 openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.p12   相关nginx配置  

server {
    listen       443 ssl;
    server_name  xuxiaobo.com;

ssl on;
    ssl_certificate ssl/server.crt; #服务器公钥地址
    ssl_certificate_key ssl/server.key; #服务器私钥地址
    ssl_client_certificate ssl/ca.crt; #CA公钥地址 验证客户端证书是否是同一CA签发
    ssl_verify_client on; #双向认证
    ssl_session_timeout 5m;
    ssl_protocols SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; #按照这个套件配置
    ssl_prefer_server_ciphers on;

    root   D:/workspace/wwwroot80;

    location / {
        index  index.php index.html index.htm;
    autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;

        if (!-e $request_filename){
               rewrite ^/(.*) /index.php last;
        }
    }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9001;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

 

 

标签:crt,ssl,openssl,认证,NGINX,client,key,SSL,server
From: https://www.cnblogs.com/xuxiaobo/p/17026718.html

相关文章

  • 使用Let's Encrypt 安装配置免费SSL 证书教程
    一、Let'sEncrypt简介Let'sEncrypt是一个由非营利性组织互联网安全研究小组(ISRG)提供的免费、自动化和开放的证书颁发机构(CA)。简单的说,借助Let'sEncrypt颁发的证......
  • 使用Let's Encrypt 安装配置免费SSL 证书教程
    一、Let'sEncrypt简介Let'sEncrypt是一个由非营利性组织互联网安全研究小组(ISRG)提供的免费、自动化和开放的证书颁发机构(CA)。简单的说,借助Let'sEncrypt颁发的证......
  • Nginx-常用配置命令
    1.文件上传大小http{ #设置nginx文件上传大小限制 client_max_body_size200M; client_body_buffer_size50M; fastcgi_intercept_errorson;}2.http转https......
  • csrf相关知识、auth认证模块、扩展auth_user表
    csrf相关知识、auth认证模块、扩展auth_user表目录csrf相关知识、auth认证模块、扩展auth_user表csrf跨站请求伪造csrf攻击原理图解csrf校验策略csrf相关装饰器auth认证模......
  • webdav服务/ddns/域名/ssl证书设置
    1.webdav服务1.1.Windowsiis自带的webdav组件默认未启用,可以启用进行设置,使用了一下,在使用浏览器或Windows资源管理器内右键添加网络位置作为客户端时比较好用,但是......
  • linux环境通过nginx转发allure报告
    前言:  自动化测试生成的allure报告一般通过jenkins生成,生成后通过jenkins的view账号进行查看,但这样就必须登录jenkins才能看到,如何不通过登录jenkins从而看到allure报告......
  • mysql show processlist的使用
    showfullprocesslist用来查看当前线程处理情况,具体信息请参考官网:https://dev.mysql.com/doc/refman/5.7/en/show-processlist.htmlshowfullprocesslist返回的结果......
  • nginx 配置反向代理和负载均衡
    环境准备主机IPcontrol01192.168.29.128nginx01192.168.29.101nginx02192.168.29.102nginx03192.168.29.103一、配置反向代理control01nginx配......
  • nginx: the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf
    Nginx如果未开启SSL模块,配置Https时将提示如题错误原因:nginx缺少http_ssl_module模块,编译安装的时候带上--with-http_ssl_module配置就行了,但是现在的情况是我的nginx已经......
  • 通过xshell在linux上安装nginx1.12.0
    0)环境安装Nginx是C语言开发,建议在Linux上运行,当然,也可以安装Windows版本,本篇则使用CentOS7作为安装环境。 0.1gcc安装安装nginx需要先将官网下载的源码进......