阿里云开启ssl证书过程记录 NGINX
作者简介:大家好,我是思无邪,2024 毕业生,某厂 Go 开发工程师.。
我的网站:https://www.yishanicode.top/ ,持续更新,希望对你有帮助。
如果文章或网站知识点有错误的地方,烦请指正!和大家一起学习,一起进步
如果感觉博主的文章还不错的话,请三连支持一下博主哦
在阿里云租用了一个云服务器,已经开启了 DNS,但是还没有配置 ssl 证书,访问的时候由于是 http 访问,因此安全性没有保障。
而且没有开启 https 会有浏览器提示不安全、搜索引擎不索引等弊端。这里开启了,今天记录一下过程。
已有的物料:
- 阿里云已经配置好的 http 服务,使用 NGINX 代理
- 新申请的 ssl 证书
一共就两步:
- 上传 ssl 证书到服务器中
- 修改 NGINX 配置并重启
上传 ssl 证书到服务器中
在阿里云服务器中下载好 NGINX 对应的 ssl 证书文件后上传到服务器。
我的上传地址:

修改 NGINX 配置并重启
这里要先看一下自己的 NGINX 是否开启了 ssl,需要保证开启
由于我用的 centos,然后用的 yum 命令安装,应该是默认开启了。
如果是自己编译的话可能会没有开启,需要重新编译开启。
查看方式:nginx -V
[root@iZbp1eg8yt9s4umtpxez9jZ cert]# nginx -V
nginx version: nginx/1.20.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.1.1k FIPS 25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-compat --with-debug --with-file-aio --with-google_perftools_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_perl_module=dynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E'
确认 ssl 开启之后需要修改对应的配置文件绑定证书的位置。
如果忘记了自己用的哪个配置文件可以使用nginx -t来查看。
[root@iZbp1eg8yt9s4umtpxez9jZ cert]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
输出显示我这里的文件是:/etc/nginx/nginx.conf。
命令行使用 vim /etc/nginx/nginx.conf 即可修改文件。
[root@iZbp1eg8yt9s4umtpxez9jZ cert]# cat /etc/nginx/nginx.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /yishanicode/src/.vuepress/dist;
index index.html;
}
error_page 404 /404.html;
location = /404.html {
root /yishanicode/src/.vuepress/dist;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
# 这里是新增的 gzip 配置
gzip on;
gzip_min_length 1k;
gzip_comp_level 6;
gzip_types application/atom+xml application/geo+json application/javascript application/x-javascript application/json application/ld+json application/manifest+json application/rdf+xml application/rss+xml application/xhtml+xml application/xml font/eot font/otf font/ttf image/svg+xml text/css text/javascript text/plain text/xml;
}
##这里之前是注释掉的 start
# Settings for a TLS enabled server.
#
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.yishanicode.top;
root /usr/share/nginx/html;
# 路径需要修改成自己对应的配置
ssl_certificate "cert/yishanicode.pem";
ssl_certificate_key "cert/yishanicode.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
## 这里的配置直接抄上面sever80的配置就行(http的配置)
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /yishanicode/src/.vuepress/dist;
index index.html;
}
error_page 404 /404.html;
location = /404.html {
root /yishanicode/src/.vuepress/dist;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
# 这里是新增的 gzip 配置
gzip on;
gzip_min_length 1k;
gzip_comp_level 6;
gzip_types application/atom+xml application/geo+json application/javascript application/x-javascript application/json application/ld+json application/manifest+json application/rdf+xml application/rss+xml application/xhtml+xml application/xml font/eot font/otf font/ttf image/svg+xml text/css text/javascript text/plain text/xml;
}
##这里之前是注释掉的 end
}
到这里保存文件,使用 nginx -s reload 重启即可。
当然也可以再使用 netstat -napt|grep 443 查看 nginx 是否开始监听 443 端口。
现在不妨访问网站看一下:首页已经可以使用https成功访问了~~~
本文由博客一文多发平台 OpenWrite 发布!
阿里云开启ssl证书过程记录 NGINX的更多相关文章
- 阿里云域名ssl证书导入aws负载均衡使用
一 .原因 由于公司战略需求,需要将阿里云的服务器迁移到aws,在迁移过程中,我们需要使用的是aws的负载均衡,可以在EC2的控制台 负载平衡位找到负载均衡.根据业务需求我们使用的是应用程序负载均衡器 ...
- 申请安装阿里云免费SSL证书
微信小程序已经全面要求使用HTTPS服务了,还有苹果商店也是,所以,实现网站HTTPS已经很有必要.要实现HTTPS就需要一个SSL证书,证书大部分都很贵,不过也有一些免费的证书服务供个人开发者使用. ...
- 阿里云申请ssl证书
申请证书(本文以阿里云服务器为背景,申请证书也以阿里云域名申请证书来作为实例) (1)登陆阿里云服务器,初次配置的用户,不建议直接搜索‘ssl证书’进行购买,因为这样购买后证书与域名对应的引导性并不强 ...
- 阿里云配置ssl证书
一.申请证书和下载证书(阿里云申请) 二.在nginx服务器上配置ssl证书 1.检查服务器是否安装openssl 2.在nginx conf 文件夹创建 cret 文件,放置证书 [root@web ...
- 阿里云服务器配置SSL证书成功开启Https(记录趟过的各种坑)
环境: 阿里云云服务器 Windows Server 2008 标准版 SP2 中文版(趁1212优惠买的一年的水货配置) 阿里云购买的域名(已备案.已解析) 服务器:phpstudy:php5 ...
- 阿里云-免费SSL证书申请及验证步骤
1.登录阿里云管理控制台,在搜索栏输入ssl,选择第一个SSL证书控制台回车即可 2.点击右上角的购买证书 3.选择购买最后一个品牌 4.选择增强型OV SSL 5.选中后会自动弹出免费型DV SSL ...
- 在阿里云购买SSL证书,让网站支持HTTPS
SSL简介 引自:https://baike.baidu.com/item/ssl/320778?fr=aladdin SSL SSL(Secure Sockets Layer 安全套接层),及其继任 ...
- 阿里云部署SSL证书详解
http://mp.weixin.qq.com/s/NV7Zad4DVEgzG2GCHYJVLw 查找中间证书 为了确保兼容到所有浏览器,我们必须在阿里云上部署中间证书,如果不部署证书,虽然安装过程可 ...
- 阿里云免费SSL证书申请与安装使用(IIS7)
准备: 阿里云已完成备案的域名一个 第一步:免费SSL证书申请 登陆阿里云平台,在域名控制台下,选择你的域名,点击“SSL”证书,如图所示 再跳转后的页面,选择“单域名免费证书”,并补全域名,非二级域 ...
- 【转】阿里云免费SSL证书申请与安装使用(IIS7)
阅读目录 准备: 第一步:免费SSL证书申请 第二步:证书导入 第三步:分配服务器证书 最后一步:访问测试 回到顶部 准备: 阿里云已完成备案的域名一个 回到顶部 第一步:免费SSL证书申请 登陆阿里 ...
随机推荐
- 惊爆!72.1K star 的 Netdata:实时监控与可视化的超炫神器!
在当今复杂的 IT 环境中,实时监控与可视化对于保障系统的稳定运行和性能优化至关重要. 无论是服务器.应用程序,还是网络设备,及时获取性能数据能够帮助我们快速定位问题.优化资源配置. Netdata, ...
- 低功耗4G模组:tcs3472颜色传感器示例
今天我们学习合宙低功耗4G模组Air780EP的LuatOS开发tcs3472示例,文末[阅读原文]获取最新资料1 一.简介 tcs3472颜色传感器能够读取照射到的物体的RGB三种数值,从而识别 ...
- [昌哥IT课堂]|欢迎 MySQL 9.0,回顾 Oracle 在 8.0 版中的管理(译)
对于新兴技术和社区的管理是相对容易的.经过 29 年发展,MySQL 已成为全球数百万用户中使用最广泛且备受信任的开源数据库之一.在这一规模的社区领导中可能存在复杂性.我们努力寻求稳定和创新的平衡,为 ...
- Mac 上常见的环境配置文件
当使用命令行终端进行开发时,环境配置文件可以用来自动化执行一些命令或设置环境变量,以提高工作效率和方便使用.在 Mac 上,常见的环境配置文件有以下几种: 1. 在.bash_profile文件中配置 ...
- element table 合并同类项并输出后台返回数据
table的样式如下 后台返回的数据格式是按照横着来的,因为表头是经过处理的,而且是作为独立出来的数据返给前端的,所以当我们进行数据填充的时候需要用到后台返回的完整的数据,要想一一对应的话,我们需要进 ...
- Jetson Orin NX烧录+设备树更改?看这一篇就够了!
Jetson Orin NX烧录+设备树更改?看这一篇就够了! 笔者的设备为Jetson Orin NX 16GB + 达妙科技的Orin NX载板 本博客同步发表在CSDN:https://blog ...
- Mybatis【6】-- Mybatis插入数据后自增id怎么获取?
代码直接放在Github仓库[https://github.com/Damaer/Mybatis-Learning/tree/master/mybatis-05-CURD ] 需要声明的是:此Myba ...
- One API 替代品 Chat Nio 安装与使用教程
有这样一位初中生,他在初一下学期发起了一个项目,专门用来给他的朋友们免费体验 GPT 模型. 到了八年级的暑假,他决定把这个项目开源出来,并且正式命名为 Chat Nio,同时项目的定位为一站式 LL ...
- QEMU CVE-2021-3947 和 CVE-2021-3929 漏洞利用分析
QEMU CVE-2021-3947 和 CVE-2021-3929 漏洞利用分析 CVE-2021-3947 信息泄露漏洞 漏洞分析 漏洞点是 nvme_changed_nslist stati ...
- vue3笔记 - 父子组件通信
父传子 说明:父组件将数据绑定在组件标签上:子组件props接收 父组件: <template> <Child :msg="msg" /> </tem ...