zoukankan      html  css  js  c++  java
  • 为你的网站加上SSL,可以使用HTTPS进行访问

    首先,我们使用的是nginx

    将域名证书文件1_www.domain.com_bundle.crt 、私钥文件2_www.domain.com.key保存到同一个目录,例如/usr/local/nginx/conf目录下。

    在ngxin配置中,添加如下:

    server {
            listen 443;
            server_name www.domain.com; #填写绑定证书的域名
            ssl on;
            ssl_certificate 1_www.domain.com_bundle.crt;
            ssl_certificate_key 2_www.domain.com.key;
            ssl_session_timeout 5m;
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
            ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
            ssl_prefer_server_ciphers on;
            location / {
                root   html; #站点目录
                index  index.html index.htm;
            }
        }

    安装ssl:

    yum -y install openssl openssl-devel

    进入nginx 源码包重新配置:

    ./configure 
    --prefix=/usr/local/nginx 
    --with-http_stub_status_module 
    --with-http_ssl_module 
    --pid-path=/var/run/nginx/nginx.pid 
    --lock-path=/var/lock/nginx.lock 
    --error-log-path=/var/log/nginx/error.log 
    --http-log-path=/var/log/nginx/access.log 
    --with-http_gzip_static_module 
    --http-client-body-temp-path=/var/temp/nginx/client 
    --http-proxy-temp-path=/var/temp/nginx/proxy 
    --http-fastcgi-temp-path=/var/temp/nginx/fastcgi 
    --http-uwsgi-temp-path=/var/temp/nginx/uwsgi 
    --http-scgi-temp-path=/var/temp/nginx/scgi 
    --add-module=/home/software/fastdfs-nginx-module/src

    以上是fastdfs + ssl的配置,如果你不需要fastdfs,那么只需要如下即可:

    ./configure 
    --prefix=/usr/local/nginx 
    --with-http_stub_status_module 
    --with-http_ssl_module 
    make
    make install

    OK,

    使用 ./nginx -t 测试是否成功

    然后重启即可访问;最后结果如下:

  • 相关阅读:
    how to design a good api and why it matters
    耦合_wiki
    python图形界面:首选Tkinter
    进程间通信:KPIPE
    记 · 今日冬至 · 除了吃还有思考
    【Nodejs】448- 深入学习 Node.js Buffer
    记 · 七言古诗 · 劝学
    【CSS】447- 纯CSS实现简单骨骼动画
    【JS】446- 你不知道的 map
    【前端知乎】445- File FileList 和 FileReader 对象详解
  • 原文地址:https://www.cnblogs.com/leechenxiang/p/7247852.html
Copyright © 2011-2022 走看看