1、首先,准备好ssl证书

nignx配置https  ---SSL_https

2、修改NGINX配置

nignx配置https  ---SSL_https_02

具体配置,参考如下:

server {
    listen 443 ssl;
    #域名或者Nginx外网IP
    server_name 172.168.3.167;
    charset utf8;

#    ssl on;
    #安全证书地址
    ssl_certificate /etc/nginx/conf.d/cert/server.crt;
    ssl_certificate_key /etc/nginx/conf.d/cert/server.key;

    ssl_session_cache shared:SSL:20m;
    ssl_session_timeout 20m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;

    proxy_redirect off;
    proxy_intercept_errors on;
    proxy_set_header Host $host;
    #proxy_set_header address $address;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Nuonuo-Log-Guid $request_id;

    client_max_body_size 1000m;
    client_body_buffer_size 128k;
    proxy_connect_timeout 30;
    proxy_send_timeout 30;
    proxy_read_timeout 30;
    proxy_buffer_size 8k;
    proxy_buffers 4 64k;
    proxy_busy_buffers_size 128k;
    proxy_temp_file_write_size 128k;

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;

    if ($request_method !~* GET|POST|HEAD) {
        return 403;
    }
}