OpenResty 配置SSL 同时支持http 全部转发到 https中

nginx 配置https
server {
listen 443 ssl;
server_name www.aidici.com;
ssl_certificate D:\aidici.com_chain.crt;
ssl_certificate_key D:\aidici.com_key.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;

    # 获取当前系统时间,并返回
    location /getTime {
        default_type text/html;
        content_by_lua '
            ngx.say(ngx.time() * 1000);
        ';   
    }
 }

将http 转发到 https中
server {
listen 80;
server_name www.aidici.com;
rewrite ^(.) https://$server_name$1 permanent; #跳转到Https
# rewrite ^/(.
) https://$server_name$request_uri permanent; #request_uri 参数 获取到的不是很对 就使用了$1这种方式
}

posted @ 2020-05-07 16:13  JC-0527  阅读(833)  评论(0编辑  收藏  举报