windows下nginx、openssl实现https文件服务器
nginx: http://nginx.org/en/download.html
openssl: http://slproweb.com/products/Win32OpenSSL.html
新建环境变量:OPENSSL_HOME为c:\openssl-Win64\bin
path变量添加:%OPENSSL_HOME%\bin
#证书生成
openssl genrsa -des3 -out xxx.key 1024
openssl req -new -key xxx.key -out xxx.csr
cp xxx.key xxx.key.org
openssl rsa -in xxx.key.org -out xxx.key
openssl x509 -req -days 365 -in xxx.csr -signkey xxx.key -out xxx.crt
修改nginx.conf后start nginx
server {
listen 443 ssl;#使用端口开启ssl
server_name localhost;
ssl_certificate C://nginx-1.18.0//ssl//xxx.crt;#证书
ssl_certificate_key C://nginx-1.18.0//ssl//xxx.key;#key
#charset koi8-r;
#access_log logs/host.access.log main;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
#虚拟目录
location /update {
alias C:/hy-8000;
allow all;
autoindex on;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_http_version 1.1;
}