本节内容:
nginx https
1,生成1024位加密的服务器私钥:
复制代码 代码示例:
openssl genrsa -des3 -out ca.simple.com
2,制作CSR证书申请文件:
复制代码 代码示例:
opensslreq -new -key ca.simple.com.key -out simple.com.csr
然后输入一系列的东西。
3,自己给自己签发证书:
复制代码 代码示例:
openssl x509 -req -days 36500 -in simple.com.csr -signkey ca.simple.com.key -out simple.com.crt
4,nginx配置:
复制代码 代码示例:
server {
server_name simple.com;
listen 443;
ssl on;
ssl_certificate /var/www/mysite/ssl/simple.com.crt;
ssl_certificate_key /var/www/mysite/ssl/ca.simple.com.key;
location ~ ^/static/ {
root /var/www/mysite/;
expires 5m;
}
location / {
#index index8080.html;
#root /usr/share/nginx/www;
proxy_pass http://mysvr;
proxy_set_header Host $host;
proxy_set_header X-REAL-IP $remote_addr;
proxy_set_header X-FORWARDED-FOR $proxy_add_x_forwarded_for;
proxy_ignore_client_abort on;
}
}