Nginx支持https访问
为了提高web应用的安全性,现在基本上都需要支持https访问。在此记录一下自己在nginx下的配置过程
- 安装Nginx这里就省略了
- 安装openssl模块
yum -y install openssl
开始生成证书
# openssl genrsa -des3 -out server.key 1024
Generating RSA private key, 1024 bit long modulus
..................................................................++++++
......................++++++
e is 65537 (0x10001)
Enter pass phrase for server.key:
Verifying - Enter pass phrase for server.key:
# ls
~ server.key
# cat server.key
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,D3E1935BAB9B90AB
8GVO2uvJf8MhMqZYlukRqbH01FDigvYqf6SNWf/TR7FZH9RkyNSezO7B9bqiL+te
3b2/ofW9xGiXDDAU4Cr7Wmg83f8vP4x9bZ19qzw0dU5PfD7IUnvVco7uwkPem8pn
# openssl req -new -key server.key -out server.csr
Enter pass phrase for server.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:`CN`
State or Province Name (full name) []:`BeiJing`
Locality Name (eg, city) [Default City]:`beijing`
Organization Name (eg, company) [Default Company Ltd]:`kingsoft`
Organizational Unit Name (eg, section) []:`kingsoft`
Common Name (eg, your name or your server's hostname) []:`vm-01`
Email Address []:`gaohongyu@kingsoft.com`
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:`12345678`
An optional company name []:`回车`
# ls
~ server.csr server.key
# cat server.csr
-----BEGIN CERTIFICATE REQUEST-----
MIICADCCAWkCAQAwgY4xCzAJBgNVBAYTAkNOMRAwDgYDVQQIDAdCZWlKaW5nMRAw
DgYDVQQHDAdiZWlqaW5nMREwDwYDVQQKDAhraW5nc29mdDERMA8GA1UECwwIa2lu
Z3NvZnQxDjAMBgNVBAMMBXZtLTAxMSUwIwYJKoZIhvcNAQkBFhZnYW9ob25neXVA
a2luZ3NvZnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCic/v6n5yd
8fZE1ibpfH0ZrtesEE8iwp008sGYQh3Zr4t23/jZWs1vScv79Pz09uXGW3Bq7HaX
CdNMMun7hf2S5LCQhSCb+9d1mZMQ+EF17NYkm+mI/+hoT48x9TIOcOMMvUTB/gxx
Idmh0ah1ZUDEQJC3oqokmApvrycA23FKFwIDAQABoDEwFgYJKoZIhvcNAQkHMQkM
BzEzMTQyNTgwFwYJKoZIhvcNAQkCMQoMCGtpbmdzb2Z0MA0GCSqGSIb3DQEBCwUA
A4GBAHtJ3qTe5cpqiSJVi8nJqBvumrAJJSVvlE8/0FnP+cmrUUvWFpHnJ2KWDu5J
XqZynUjBjw8nXsxs62s+Z2DuMqWByRhVODABX6o/DoQ/5AMHY0prmwn1CgQOINeQ
WTXKsVFFuK3nVWUp53RheOcl1mN864K5gq7lBxVuV+3U8/88
-----END CERTIFICATE REQUEST-----
# cp server.key server.key.org
# openssl rsa -in server.key.org -out server.key
Enter pass phrase for server.key.org:
writing RSA key
# openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Signature ok
subject=/C=CN/ST=BeiJing/L=beijing/O=kingsoft/OU=kingsoft/CN=vm-01/emailAddress=gaohongyu@kingsoft.com
Getting Private key
Nginx配置https
vim nginx.conf 新增server节点,配置如下:
server {
server_name localhost;
listen 443 ssl;
ssl on;
ssl_certificate /usr/local/nginx/conf/crt/server.crt;
ssl_certificate_key /usr/local/nginx/conf/crt/server.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
}
重启nginx验证:nginx -s reload
打开浏览器验证:https://IP/index.html
Nginx支持https访问的更多相关文章
- nginx 支持https访问
1,先确认nginx安装时已编译http_ssl模块. 就是执行nginx -V命令查看是否存在--with-http_ssl_module.如果没有,则需要重新编译nginx将该模块加入.yum安装 ...
- 配置nginx支持Https
配置nginx支持Https一定要先使用stop停止nginx然后重新代开不能使用reload 一:安装letsencrypt 1.从git上克隆下来git clone https://github. ...
- 安装配置ingress-nginx支持https访问
说明: 1.k8s版本:v1.23: 2.内网测试环境1台master,2台node节点,使用 DaemonSet+HostNetwork+nodeSelector 方式部署 ingress- ...
- 微信小程序如何提交审核并发布?发布问题:小程序只支持https访问
http://www.jisuapp.cn/news/305.html 发布问题:1.小程序只支持https访问 2.要配置服务域名
- libcurl 不支持https访问
项目中使用libcurl 访问https的时候会报错,比如:“Unsupported protocol” 或者:“Protocol https not supported or disabled in ...
- nginx使用ssl模块配置支持HTTPS访问
默认情况下ssl模块并未被安装,如果要使用该模块则需要在编译nginx时指定–with-http_ssl_module参数. 需求: 做一个网站域名为 www.localhost.cn 要求通过htt ...
- nginx使用ssl模块配置支持HTTPS访问【解决ssl错误】
默认情况下ssl模块并未被安装,如果要使用该模块则需要在编译nginx时指定–with-http_ssl_module参数. 需求:做一个网站域名为 www.localhost.cn 要求通过http ...
- nginx使用ssl模块配置支持HTTPS访问,腾讯云申请免费证书
开始我尝试用 let's encrypt 让http 变 https 官方:https://github.com/certbot/certbot 参考:https://www.cnblogs.com/ ...
- nginx配置https访问
一.准备 环境:centos6.8 nginx:1.13.6 二.开始 首先安装依赖包: yum install -y gcc gcc-c++ autoconf automake make ...
- windows下搭建nginx服务器及实现nginx支持https配置流程
最近刚接触到了tomcat结合nginx做网站的负载均衡.之前对tomcat搭配nginx实现负载均衡也写过,在上一篇的博客中,最近遇到的问题是要在http的基础上支持https.也就是支持加密的请求 ...
随机推荐
- yum下载包保存到本地
1.使用yumdownloadonly下载RPM包及依赖包 #下载yumdownloadonly插件 yum install yum-plugin-downloadonly # yum 下载rpm包到 ...
- SNMP基础概念
一.什么是SNMP? SNMP=Simple Network Management Protocol (简单网络管理协议) SNMP是被广泛接受并投入使用的工业标准,提供了一个框架来定义管理信 ...
- Python 绘制 K 线图
import mplfinance as mpf import pandas as pd # 示例数据 data = pd.DataFrame({ 'Date': ['2023-01-01', '20 ...
- spring boot 若依系统整合Ueditor,部署时候上传图片错误解决
spring boot 若依系统整合Ueditor,部署时候上传图片错误解决 前言:国庆假期找了个ruoyi版本的cms玩玩,从git上看,介绍如下图: 后台部分截图: 编辑 编辑 编辑 ...
- drawable xx should not reference itself
背景: 在Android中新增一个xx.xml,在layer-list 的item中设定引入的drawable后,报这个提示(xx不能引用自身) 原因: 这个错误其实很离谱,但是还是有必要记一下,万一 ...
- linux 前端部署 tomcat 脚本
前提: 打包后的文件位置:/home/usr/back 目的部署位置:/home/usr/prod1 目的部署位置:/home/usr/prod2 在linux 服务器上 新增文件deploy-web ...
- THREE.JS中 CubeTextureLoader 使用避坑
最近在跟着教程学THREE.JS,毕竟在现在的前端开发市场上,THREE.JS太火爆了. 今天学到"纹理"这一块的时候,跟着教程敲代码,发现自己的没有正确显示,百思不得其解,打开控 ...
- Angular Material 18+ 高级教程 – CDK Overlay
Overlay, Dialog, Modal, Popover 傻傻分不清楚 参考: Medium – Modal?Dialog?你真的知道他們是什麼嗎? Popups, dialogs, toolt ...
- Electron加载服务器端JS:高效打造跨平台桌面应用与本地 API 交互
在现代桌面应用开发中,使用 Electron 加载远程服务器托管的前端资源,再与本地 API 交互,能够带来灵活的部署和强大的本地功能支持.这种方式不仅提升了开发效率,还能充分利用 PC 端的资源和性 ...
- 面试被问到:fiddler 在工作中有哪些应用?怎么破?
作为软件测试工程师,如果你的简历中有涉及到 fiddler 这款工具,出去面试可能会被问到:fiddler 在工作中有哪些应用? 我们都知道 fiddler 是一款非常优秀的调试代理工具,用于记录客户 ...