adonis nginx https ssl配置

2018-11-05  本文已影响0人  实验石

配置内容

server {
        listen 80;
        server_name abc.cn;
        client_max_body_size 1000m;
        location / {
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header Host  $http_host;
              proxy_set_header X-Nginx-Proxy true;
              proxy_set_header Connection "";
              proxy_pass     http://127.0.0.1:3333;
        }
}

ssl https配置

申请的腾讯云的免费ssl,申请很快。

server {
        listen 80;
        server_name h5.abc.cn;
        client_max_body_size 1000m;
        location / {
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header Host  $http_host;
              proxy_set_header X-Nginx-Proxy true;
              proxy_set_header Connection "";
              proxy_pass     http://127.0.0.1:5555;
        }
        
        listen 443 ssl;
        ssl on;
        ssl_certificate /etc/nginx/key/1_h5.abc.cn_bundle.crt;
        ssl_certificate_key /etc/nginx/key/2_h5.abc.cn.key;
        
}

不能强制http跳转到https,试了几个都不行,不知道怎么配置

--

server {
        listen 443 ssl;
        ssl on;
        ssl_certificate /var/www/h5.abc.cn/resources/zhengshu/1_h5.abc.cn_bundle.crt;
        ssl_certificate_key /var/www/h5.abc.cn/resources/zhengshu/2_h5.abc.cn.key;
        server_name h5.abc.cn;
        client_max_body_size 1000m;
        location / {
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header Host  $http_host;
              proxy_set_header X-Nginx-Proxy true;
              proxy_set_header Connection "";
              proxy_pass     http://127.0.0.1:3333;
        }
}

server {
listen 80;
server_name h5.abc.cn;
rewrite ^(.*) https://$server_name$1 permanent;
}

嗯,经测试,上面可以实现 http 自动跳转到https。

网站放在linode jp2站点,使用cloudflare加速,速度块一丢丢。
不加速:


image.png

加速后:


image.png

又测试了一次,都是平均135左右,低于130都没有了。

别忘记在 cloudflare 中添加ssl的_dnsauth

上一篇下一篇

猜你喜欢

热点阅读