域名cdn加速(apache与nginx)

一:

  由于公司业务属于请求量比较大的吧,每个月几亿条,考虑到安全性,所以需要域名由http改为https,cdn加速才可以支成撑业务。

二:

  之前的系统是使用lamp配置的,这次以nginx为示例:

  nginx配置:

server {
    listen 443;
    server_name xxx.com;  # localhost修改为您证书绑定的域名。
    ssl on;   #设置为on启用SSL功能。
    root html;
    index index.html index.htm;
    ssl_certificate .pem路径;   #将domain name.pem替换成您证书的文件名。
    ssl_certificate_key .key路径;   #将domain name.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; 
      
    # location / {
    #     root html;
    #     index index.html index.htm;   
    # }

    location / {
        proxy_pass https://xxx.com;
        index  index.html index.htm index.php;
        root   项目路径;
        if (!-e $request_filename){   
            rewrite ^(.*)$ /index.php/?s=$1 last; # TP rewrite模式
            break;
        }
        
        # 显示真实ip地址
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        autoindex on;
    }   

    location ~ \.php {
        root           项目路径;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }   

}

两个文件为aliyun上面下载的免费的证书,路径为在你nginx路径下新建cert文件夹,放入即可

配置完后重启nginx 

systemctl restart nginx.service

三:

咱们既然做cdn加速,就要有域名加速,给你的域名备案,我这里就不赘述了。

cdn aliyun配置:

配置完成后你会获取一个cname,域名解析用的到

域名解析:

解析完成后就可以访问带https的cdn加速的访问了

设置nginx重启:systemctl enable nginx.service

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值