关于nginx:ssl证书结合Nginx搭建https站点免费证书

50次阅读

共计 730 个字符,预计需要花费 2 分钟才能阅读完成。

创立 ssl 证书

 $ mkdir -p /etc/nginx/ssl
 $ cd /etc/nginx/ssl
 $ openssl genrsa -idea -out server.key 1024
 $ openssl req -new -key server.key -out server.csr
 $ openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt

留神要加过期工夫,默认的有效期很短

Nginx 配置

  $ cd /etc/nginx/conf.d
  $ vim https.conf

输出以下内容

     server {
        listen       443 ssl http2 default_server;
        listen       [::]:443 ssl http2 default_server;
        server_name  _;
        root         /usr/share/nginx/html;
        ssl_certificate "/etc/nginx/ssl/server.crt";
        ssl_certificate_key "/etc/nginx/ssl/server.key";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers PROFILE=SYSTEM;
        ssl_prefer_server_ciphers on;
        location / { }

        error_page 404 /404.html;
            location = /40x.html { }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {}}

保留退出并重启 nginx

因为咱们的证书没有给相干机构认证,所以还是提醒不平安,然而不影响咱们测试应用

正文完
 0