Nginx配置ssl安全证书

Posted minseo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx配置ssl安全证书相关的知识,希望对你有一定的参考价值。

server {
        listen       443;
        server_name  www.loaclhost.com;
        ssl  on;
        root   /web;
        ssl_certificate      /data/ssl/xxx.crt;
        ssl_certificate_key  /data/ssl/xxx.key;
        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;
        ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers  HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM;
        ssl_prefer_server_ciphers  on;

        location / {
            index  index.html index.htm index.php;
        }
        location ~ .*\.(php|php5)?$ {
             fastcgi_pass  127.0.0.1:9000;
             fastcgi_index index.php;
             include fastcgi.conf;
             fastcgi_param HTTPS $https if_not_empty;
       }
        access_log  logs/ssl_access.log  main;
        error_log  logs/ssl_error.log  notice;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

配置如上所示,可以设置rewrite规则强制跳转https

以上是关于Nginx配置ssl安全证书的主要内容,如果未能解决你的问题,请参考以下文章

linux nginx ssl证书怎么配置

Nginx 配置https证书认证

Nginx 配置https证书认证

nginx配置ssl证书后无法访问https

nginx配置SSL证书

nginx开启ssl配置https证书和密钥过程