-

1)

1)申请证书,这里以申请免费证书为例

参考博客申请即可https://blog.csdn.net/weixin_41827162/article/details/100688681

1-1)【DNS法验证(如果选择了文件法验证,就根据官方教程引导完成文件验证即可)】绑定并验证域名:

利用工具得到如下文件:

2)在nginx服务器新建目录,并将两个文件放入其中:

2-1)更改nginx.conf文件,加入如下内容:

 server {listen 80;listen 443 ssl;server_name api.cswendu.com;index index.php index.html index.htm;root  /home/wwwroot/default;#ssl on;   # 为了保证http和https都能访问,这行必须要注释掉ssl_certificate /usr/local/nginx/conf/https/api.cswendu.com_chain.crt;ssl_certificate_key /usr/local/nginx/conf/https/api.cswendu.com_key.key;# 省略其他操作# ...}

完整nginx.conf文件内容如下:

user  www www;worker_processes auto;
worker_cpu_affinity auto;error_log  /home/wwwlogs/nginx_error.log  crit;pid        /usr/local/nginx/logs/nginx.pid;#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;events{use epoll;worker_connections 51200;multi_accept off;accept_mutex off;}http{include       mime.types;default_type  application/octet-stream;server_names_hash_bucket_size 128;client_header_buffer_size 32k;large_client_header_buffers 4 32k;client_max_body_size 50m;sendfile on;sendfile_max_chunk 512k;tcp_nopush on;keepalive_timeout 60;tcp_nodelay on;fastcgi_connect_timeout 300;fastcgi_send_timeout 300;fastcgi_read_timeout 300;fastcgi_buffer_size 64k;fastcgi_buffers 4 64k;fastcgi_busy_buffers_size 128k;fastcgi_temp_file_write_size 256k;gzip on;gzip_min_length  1k;gzip_buffers     4 16k;gzip_http_version 1.1;gzip_comp_level 2;gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;gzip_vary on;gzip_proxied   expired no-cache no-store private auth;gzip_disable   "MSIE [1-6]\.";#limit_conn_zone $binary_remote_addr zone=perip:10m;##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.server_tokens off;access_log off;server {listen 80 default_server reuseport;#listen [::]:80 default_server ipv6only=on;server_name _;index index.php index.html index.htm;root  /home/wwwroot/default;#astcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param   PATH_INFO   $fastcgi_path_info;fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;#error_page   404   /404.html;# Deny access to PHP files in specific directory#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }location / {try_files $uri $uri/ /index.php?$query_string;}include enable-php.conf;location /nginx_status{stub_status on;access_log   off;}location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${expires      30d;}location ~ .*\.(js|css)?${expires      12h;}location ~ /.well-known {allow all;}location ~ /\.{deny all;}access_log  /home/wwwlogs/access.log;}server {listen 80;listen 443 ssl;server_name api.cswendu.com;index index.php index.html index.htm;root  /home/wwwroot/default;#ssl on;   # 为了保证http和https都能访问,这行必须要注释掉ssl_certificate /usr/local/nginx/conf/https/api.cswendu.com_chain.crt;ssl_certificate_key /usr/local/nginx/conf/https/api.cswendu.com_key.key;#astcgi_split_path_info ^(.+\.php)(/.+)$;fastcgi_param   PATH_INFO   $fastcgi_path_info;fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;#error_page   404   /404.html;# Deny access to PHP files in specific directory#location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }location / {try_files $uri $uri/ /index.php?$query_string;}include enable-php.conf;location /nginx_status{stub_status on;access_log   off;}location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${expires      30d;}location ~ .*\.(js|css)?${expires      12h;}location ~ /.well-known {allow all;}location ~ /\.{deny all;}access_log  /home/wwwlogs/access.log;}include vhost/sites.conf;
}

3)重启nginx服务器即可。

service nginx restart

成功:

-

nginx绑定https证书,保证http和https都能访问相关推荐

  1. 免费申请 HTTPS 证书,开启全站 HTTPS

    HTTP 报文以明文形式传输,如果你的网站只支持 HTTP 协议,那么就有可能遭受到安全攻击.你可以使用 Google 浏览器打开一个 HTTP 协议网站,会发现 Chrome 在网址的左边将这个网站 ...

  2. Android https证书过期,Android 的 HTTPS 证书过期异常

    8种机械键盘轴体对比 本人程序员,要买一个写代码的键盘,请问红轴和茶轴怎么选? 对于 HTTPS 服务器证书过期的问题,由于 Android 安全库的不断更新,尽管在证书验证的时候抛出的异常大同小异, ...

  3. https 443 怎么改成80_阿里云购买免费https证书并用nginx配置代理详解(2020年9月)...

    现在各大网站都转型https协议了,连ios app上架都必须走https协议了,那么如何将我们普通的小网站统一变成https呢? 1.https证书购买及绑定域名 https证书都不便宜,现在服务器 ...

  4. 阿里云购买免费https证书并用nginx配置代理详解(2020年9月)

    现在各大网站都转型https协议了,连ios app上架都必须走https协议了,那么如何将我们普通的小网站统一变成https呢? 阿里云ssl证书购买地址:证书服务_SSL数字证书_HTTPS加密_ ...

  5. 实施经验-https证书理解

    文章目录 先从一个需求案例说起 流程梳理 在https协议中是如何使用证书的 概念梳理 openssl参数说明 参考: 先从一个需求案例说起 给甲方的web服务需要使用https,是部署在内网的,连域 ...

  6. HTTPS证书基本概述

    https证书 为什么需要使用HTTPS 因为 HTTP 不安全,当我们使用 http 网站时,会遭到劫持和篡改,如果采用 https 协议,那么数据在传输过程中是加密的,所以黑客无法窃取或者篡改数据 ...

  7. 如何获取网站的HTTPS证书?

    如果你的网站需要收集敏感信息(包括电子邮件和密码等),那么就需要保证网站的安全.最好的方法之一是启用HTTPS,以便自动加密进出服务器的任何信息,防止黑客窃取和篡改访客的信息. HTTPS超文本传输协 ...

  8. https证书自签名

    在网络里有很多病毒是人们不能了解的,所以在自己的网站里安装安全证书是很重要的,现在小编就对于https证书自签名和https双向认证来给大家介绍一下他们的知识.我们知道了这些知识以后我们在自己的网站里 ...

  9. 微信公众平台(3):微信小程序发布为什么需要https证书

    微信小程序一定要用https的理由,小程序使用HTTPS链接分析 一.HTTPS HTTPS是HTTP的安全版,在HTTP的基础上加入SSL证书 (服务器证书)后形成的安全协议,不但可以建立信息加密通 ...

  10. 查看域名https证书的起止时间

    通过域名查看: // 查看https证书的起止时间(假设域名为 "jinfu.im") echo | openssl s_client -servername jinfu.im - ...

最新文章

  1. big endian little endian
  2. Windows杀死结束进程图形化界面操作方法
  3. 【数据结构与算法】之深入解析“填充每个节点的下一个右侧节点指针”的求解思路与算法示例
  4. LeetCode 220. 存在重复元素 III(lower_bound)
  5. flex 布局,flex-grow 宽度未等比放大问题解决办法
  6. volume image
  7. 英语本科 国外跨计算机,跨专业考研需具备哪些条件,如英语,计算机的过级情况...
  8. 游戏开发之深拷贝与浅拷贝(C++基础)
  9. 二十、K8s集群设置2- HTTPS-CFSSL
  10. 会话技巧---英文单词
  11. a链接实现alt提示
  12. c++ 与 数据结构 实现 《校园路径导航系统》
  13. 【他来了】云顶之奕 手游账号注册!国服可玩!
  14. html国庆节代码,小程序10行代码实现微信头像挂红旗,国庆节个性化头像
  15. 康奈尔大学的计算机专业怎么样,康奈尔大学研究生院计算机专业怎么样?
  16. 案例分析|人工智能产品带来的用户价值
  17. 概率分析和随机算法_雇佣问题
  18. 使用高德地图服务获取全部行政区划与各个省市的地理坐标
  19. 深度丨从零搭建推荐体系
  20. 基于改进YOLOv5的挖机铲斗缺陷检测系统(源码&教程)

热门文章

  1. JAVA输入最低的手机店的价格(初学期)
  2. 小程序开发,唯一一个稳定的版本,其他的都白屏,微信这帮子开发人员真是垃圾
  3. 2021年茶艺师(初级)报名考试及茶艺师(初级)考试资料
  4. 【diannaoxitong】虚拟货币有哪些?网络虚拟货币汇总
  5. android安装Mysql服务,android手机可以作为mysql的服务器
  6. 成都七中食品霉变!只有新技术才能真的解决食品安全问题
  7. Affinity photo中文教程 第一课:Affinity photo简介
  8. Python学习日记10
  9. STM32使用MPU6050在TFT_LCD上显示数据
  10. 强智科技教务系统验证码识别