博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
http => https 升级
阅读量:4673 次
发布时间:2019-06-09

本文共 2590 字,大约阅读时间需要 8 分钟。

准备证书

  • 阿里云安全(云盾)-> CA证书服务,购买证书,个人测试的话可以使用免费的,期限1年。
  • 购买证书后,把域名与证书进行绑定,提交审核,大概10分钟左右,正常情况下审核就可以通过。证书准备完成。

安装nginx

  • apt-get update
  • apt-get upgrade
  • apt-get install nginx
  • nginx -v

默认监听80端口,输入ip/域名(如果域名已解析)即可打开nginx默认的html页面。

升级为https

制作测试站点

  • 把自己的项目部署文件放到 /var/wwww/ 目录下
  • cd /etc/nginx/sites-available
  • ls 可以看到nginx默认的配置,可以使用 vi default 编辑配置内容
  • 拷贝一个:cp default wxzs.cn(一般以项目名称命名)
  • vi wxzs.cn

    `

    server {    listen 80;    # SSL configuration    #    # listen 443 ssl default_server;    # listen [::]:443 ssl default_server;    #    # SSL configuration    #    # listen 443 ssl default_server;    # listen [::]:443 ssl default_server;    #    # Note: You should disable gzip for SSL traffic.    # See: https://bugs.debian.org/773332    #    # Read up on ssl_ciphers to ensure a secure configuration.    # See: https://bugs.debian.org/765782    #    # Self signed certs generated by the ssl-cert package    # Don't use them in a production server!    #    # include snippets/snakeoil.conf;    # 发布目录    root /var/www/wxzs.cn;    # Add index.php to the list if you are using PHP    index index.html index.htm index.nginx-debian.html;    # 服务名称    server_name wxzs.cn;    location / {            # First attempt to serve request as file, then            # as directory, then fall back to displaying a 404.            try_files $uri $uri/ =404;    }    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000    #    #location ~ \.php$ {    #       include snippets/fastcgi-php.conf;    #    #       # With php7.0-cgi alone:    #       fastcgi_pass 127.0.0.1:9000;    #       # With php7.0-fpm:    #       fastcgi_pass unix:/run/php/php7.0-fpm.sock;    #}    # deny access to .htaccess files, if Apache's document root    # concurs with nginx's one    #    #location ~ /\.ht {    #       deny all;    #}}

    `

  • cd /etc/nginx/sites-enabled
  • 执行 ll 可以是软连接到/etc/nginx/sites-available
  • ln -s /etc/nginx/sites-available/wxzs.cn .

此时

使用CA证书

  • 从阿里云下载证书,并上传到服务器
  • cd /etc/nginx
  • mkdir cert 把证书放入该目录中,并解压

  • 修改自己的站点配置:wxzs.cn ,当然一个配置中可以有多个server配置

    `

    server {    listen 443;    server_name wxzs.cn;    ssl on;    # 发布文件目录    root /var/www/wxzs.cn;     index index.html index.htm;    ssl_certificate   cert/214291297430106.pem;    ssl_certificate_key  cert/214291297430106.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;    }}

    `

此时再输入:https://域名 即可访问了。

转载于:https://www.cnblogs.com/tianboblog/p/9360576.html

你可能感兴趣的文章
第四周作业 简单地邮件发送实现
查看>>
[转载]读史记札记26:容人岂皆有雅量
查看>>
【Xilinx-Petalinux学习】-02-建立PetaLinux工程
查看>>
TeX中的引号
查看>>
Python 模块(module)
查看>>
region实现大纲效果
查看>>
[洛谷P4234]最小差值生成树
查看>>
LiveNVR传统安防摄像机互联网直播-二次开发相关的API接口
查看>>
LiveNVR高性能稳定RTSP、Onvif探测流媒体服务配置通道接入海康、大华等摄像机进行全终端无插件直播...
查看>>
c c++ sizeof
查看>>
Intellij IDEA连接Spark集群
查看>>
最长回文子串解法
查看>>
代码优化程序性能
查看>>
腾讯实习生招聘笔试题目
查看>>
Java Socket编程----通信是这样炼成的
查看>>
作业要求 20180925-1 每周例行报告
查看>>
1078. Hashing (25)-PAT甲级真题
查看>>
SQLite中的运算符表达式
查看>>
Grid使用 & ComboBox Binding & DateTime Format WPF
查看>>
.Net Core迁移到MSBuild的多平台编译问题
查看>>