Windows上利用openssl自制SSL证书

1、下载并安装openssl

Openssl下载地址

下载该exe文件后,双击下一步傻瓜式安装

2、配置path环境变量

配置完成后,在cmd窗口执行"openssl version"命令,验证是否完成安装。

3、生成ssl私钥

bash 复制代码
openssl genrsa -out D:\cert\private.key 2048
bash 复制代码
openssl req -new -key D:\cert\private.key -out D:\cert\request.csr

4、生成ssl证书

bash 复制代码
openssl x509 -req -in D:\cert\request.csr -signkey D:\cert\private.key -out D:\cert\certificate.crt -days 365

5、验证ssl证书

bash 复制代码
openssl x509 -in D:\cert\certificate.crt -text -noout

6、nginx配置https

(1)将生成的证书文件拷贝到指定目录

(2)打开nginx.conf文件配置相关参数

bash 复制代码
 server {
       listen       8080 ssl;
       server_name  192.168.5.109;
	
	   ssl_certificate D:/Server/nginx-1.22.0/cert/certificate.crt;
       ssl_certificate_key D:/Server/nginx-1.22.0/cert/private.key;
		
	   ssl_session_cache    shared:SSL:10m;
       ssl_session_timeout  5m;
 
       ssl_ciphers  HIGH:!aNULL:!MD5;
       ssl_prefer_server_ciphers  on;

       location / { 
            proxy_pass   http://127.0.0.1:8765;
			limit_conn perip 10;
			limit_conn perserver 100;
			limit_rate_after 100M;
			limit_rate 10k;
			proxy_redirect off ; 
			proxy_set_header Host $host; 
			proxy_set_header X-Real-IP $remote_addr; 
			proxy_set_header REMOTE-HOST $remote_addr; 
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_set_header X-Forwarded-Proto $scheme;			
			client_max_body_size 50m; 
			client_body_buffer_size 2560k; 
			proxy_connect_timeout 1; 
			proxy_send_timeout 300; 
			proxy_read_timeout 3000; 
			proxy_buffer_size 2560k; 
			proxy_buffers 4 2560k; 
			proxy_busy_buffers_size 2560k; 
			proxy_temp_file_write_size 2560k; 
			proxy_next_upstream error timeout invalid_header http_500 http_503 http_404; 
			proxy_max_temp_file_size 128m; 
        }


        #若是http请求自动跳转到https,端口为公网地址端口
        error_page 497 https://$host:8380$request_uri;
		
        error_page   500 502 503 504  /50x.html;
		
        location = /50x.html {
            root   html;
        }



}
相关推荐
80s7774 小时前
什么是动态IP?静态IP和动态IP有什么区别?
网络·网络协议·tcp/ip
m0_617493947 小时前
SSLError [ASN1: NOT_ENOUGH_DATA] 问题排查与解决指南
python·ssl
IPdodo_9 小时前
代理 IP 服务商 SLA 怎么验?7 项指标与 Python 探测脚本实战
运维·python·网络协议·网络安全·代理ip
夜月yeyue10 小时前
SOME/IP-SD 服务发现故障
网络·单片机·网络协议·tcp/ip·安全·服务发现
2501_9160088911 小时前
iOS App 请求地址查看,不用配置看到 App 调了哪些接口
网络协议·计算机网络·网络安全·ios·adb·https·udp
爱学堂IT分享13 小时前
码神之路-Netty-从零实现RPC框架+SpringBoot实战项目教程
spring boot·网络协议·rpc
Shawn Dev16 小时前
没有公网 IP,如何让家里的服务器通过域名访问?——Cloudflare Tunnel 实战指南
服务器·网络协议·tcp/ip
幻步智能网络云专线16 小时前
幻步智能网络专线的优势
网络·网络协议
虎王物联16 小时前
Nginx反向代理实现IoT设备HTTPS接入:从证书配置到MQTT over WebSocket实战
运维·物联网·nginx·https
深圳市宝华视联1 天前
Python 读取 IP 视频流简单 Demo
python·嵌入式硬件·opencv·网络协议·tcp/ip·实时音视频·嵌入式实时数据库