阿里云开启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证书申请 登陆阿里 ...
随机推荐
- Linux下使用谷歌输入法
Linux的中文输入法一直太烂,scim终于出来对googlePinyin的支持了. 安装步骤: 1.安装scim: sudo apt-get install scim 2.从git上checkout ...
- 常见Java面试题 – 第三部分:重载(overloading)与重写(overriding)
ImportNew注: 本文是ImportNew编译整理的Java面试题系列文章之一.你可以从这里查看全部的Java面试系列. 这篇文章介绍的常见面试题是关于重载(overloading)方法和重写( ...
- Nuxt.js 应用中的 webpack:done 事件钩子
title: Nuxt.js 应用中的 webpack:done 事件钩子 date: 2024/11/26 updated: 2024/11/26 author: cmdragon excerpt: ...
- nodejs版本管理工具之nvm
有时候 项目中依赖不同版本的node,这就需要我们使用一个版本管理工具 有序的管理这些node,这里介绍使用nvm GitHub地址:https://github.com/nvm-sh/nvm 前提: ...
- manim边做边学--文字的创建与销毁
本篇开始介绍Manim中的动画模块,动画模块是整个框架的核心魅力所在. Manim不仅提供了可以直接实现各种各样动画效果的对象, 还提供了设置动画的时长.延迟时间以及运动速率等参数,可以据此发挥自己的 ...
- Element Plus组件v-loading在el-dialog组件上使用无效
前情 公司有经常需要做一些后台管理页面,我们选择了Element Plus,它是基于 Vue 3,面向设计师和开发者的组件库,是Vue框架生态中比较火的UI组件库,组件库丰富易用,组件链接:一个 Vu ...
- 适配器模式应用~获取IP地址时想起了适配器
获取IP地址信息时,一般我们需要一个HttpServletRequest对象,然后从请求头里获取x-forwarded-for的值,而当我们使用dubbo+netty开发rest接口时,如果希望获取I ...
- Flutter问题 Flutter MissingPluginException(No implementation found for method xxx on channel xxx)
问题如题 有时候项目跑着跑着突然控制台就报了这个错,用hot restart也没有用,问题的本质是plugin没有找到,这时候有两种方法 flutter clean,会将依赖清除,这时候再重新pub ...
- HttpClientFactory in ASP.NET Core 2.1 Part 1 介绍
HttpClientFactory in ASP.NET Core 2.1 Part 1 原文地址:https://www.stevejgordon.co.uk/introduction-to-htt ...
- React 的界面与数据分离问题
React 生态庞大,没办法只能学一点.第一段学完就有一个根本性的问题了:它竟然把数据.业务逻辑和界面混在一起,组件变成了有"业务状态"的组件,这就意味着UI和业务绑定了.而这种糟 ...