Nginx强制启用https

方式一:

通过 nginx 的 rewrite 模块,进行重定向

server {
    listen       80;
    server_name  domain;
    root /www/domain;

    # rewrite 重定向
    rewrite ^(.*)$   https://$host$1 permanent;
}

server {
    listen 443 ssl;
    server_name domain;
    root /www/domain;

    location / {
        index index.html;
    }

    ssl_certificate certs/domain.pem;
    ssl_certificate_key certs/domain.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
}
Posted in PHP

发表评论

您的电子邮箱地址不会被公开。