Nginx配置开启HTTPS

  1. 获取证书文件
    Nginx配置开启HTTPS_第1张图片
  2. Nginx 开启SSL
server {
        listen       443 default ssl;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        proxy_set_header Host $host;

        ssl_certificate /usr/local/nginx/cert/server.pem;
        ssl_certificate_key /usr/local/nginx/cert/ca.key;
        ssl_session_cache   shared:SSL:128m;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
        ssl_prefer_server_ciphers on;
        
        location / {
            root   html;
            index  index.html index.htm;
            try_files $uri /index.html;
        }
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
  1. 重启Nginx
cd ../sbin
./nginx -s reload

你可能感兴趣的:(Nginx,nginx,https,运维)