基于openresty配置https访问
1. openssl的版本信息
- [root@localhost conf]# openssl version
- OpenSSL 1.0.1e-fips 11 Feb 2013
2. openresty的版本信息
- [root@localhost sbin]# ./nginx -V
3. 创建服务器私钥,命令会提醒输入一个密码,必须输入(在nginx的conf所在的路径下进行操作,当然也可以在其他路径,需要配合后续的nginx的配置一起改变)
- [root@localhost conf]# openssl genrsa -des3 -out server.key
- Generating RSA private key, bit long modulus
- ..............................................................++
- ........................++
- e is (0x10001)
- Enter pass phrase for server.key:
- :error::lib():UI_set_result:result too small:ui_lib.c::You must type in to characters
- Enter pass phrase for server.key:
- :error::lib():UI_set_result:result too small:ui_lib.c::You must type in to characters
- Enter pass phrase for server.key:
- Verifying - Enter pass phrase for server.key:
- [root@localhost conf]# ll
- 总用量
- -rw-r--r--. root root 3月 : fastcgi.conf
- -rw-r--r--. root root 3月 : fastcgi.conf.default
- -rw-r--r--. root root 3月 : fastcgi_params
- -rw-r--r--. root root 3月 : fastcgi_params.default
- -rw-r--r--. root root 3月 : koi-utf
- -rw-r--r--. root root 3月 : koi-win
- -rw-r--r--. root root 3月 : mime.types
- -rw-r--r--. root root 3月 : mime.types.default
- -rw-r--r--. root root 3月 : nginx.conf
- -rw-r--r--. root root 3月 : nginx.conf.default
- -rw-r--r--. root root 3月 : scgi_params
- -rw-r--r--. root root 3月 : scgi_params.default
- -rw-r--r-- root root 7月 : server.key
- -rw-r--r--. root root 3月 : uwsgi_params
- -rw-r--r--. root root 3月 : uwsgi_params.default
- -rw-r--r--. root root 3月 : win-utf
4. 创建签名请求的证书(CSR)
- [root@localhost conf]# 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 ( letter code) [XX]:cn
- State or Province Name (full name) []:hubei
- Locality Name (eg, city) [Default City]:wuhan
- Organization Name (eg, company) [Default Company Ltd]:tk
- Organizational Unit Name (eg, section) []:iflab
- Common Name (eg, your name or your server's hostname) []:root
- Email Address []:shihuc@.com
- Please enter the following 'extra' attributes
- to be sent with your certificate request
- A challenge password []:shihuc
- An optional company name []:tk
- [root@localhost conf]#
5. 在加载SSL支持的Nginx服务器上,使用上述私钥时除去必须的口令(注意,所谓除去,其实就是将必须的私钥密码写入到了私钥文件里面了,更新了原来的私钥文件)
- [root@localhost conf]# cp server.key server.key.org
- [root@localhost conf]#
- [root@localhost conf]# openssl rsa -in server.key.org -out server.key
- Enter pass phrase for server.key.org:
- writing RSA key
- [root@localhost conf]#
6. 通过openssl的x509指令生产证书文件
- [root@localhost conf]# openssl x509 -req -days -in server.csr -signkey server.key -out server.crt
- Signature ok
- subject=/C=cn/ST=hubei/L=wuhan/O=tk/OU=iflab/CN=root/emailAddress=shihuc@.com
- Getting Private key
7. nginx的简单配置
- # HTTPS server
- #
- server {
- listen ssl;
- server_name localhost;
- ssl_certificate server.crt;
- ssl_certificate_key server.key;
- ssl_session_cache shared:SSL:1m;
- ssl_session_timeout 5m;
- ssl_ciphers HIGH:!aNULL:!MD5;
- ssl_prefer_server_ciphers on;
- location / {
- root html/SSLROOT;
- index index.html index.htm;
- }
- }
在nginx的html目录下,创建SSLROOT目录,并在下面创建一个index.html的页面,用于测试。
8. 一个用于转发的nginx.conf文件
- worker_processes ;
- error_log logs/error.log;
- events {
- worker_connections ;
- }
- http {
- keepalive_timeout ;
- sendfile on;
- log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- '$status $body_bytes_sent "$http_referer" '
- '"$http_user_agent" "$http_x_forwarded_for"';
- server {
- listen ssl;
- # listen ssl;
- server_name localhost;
- ssl_certificate kaili.axinfu.com.crt;
- ssl_certificate_key kaili.axinfu.com.key;
- ssl_session_cache shared:SSL:1m;
- ssl_session_timeout 5m;
- ssl_ciphers HIGH:!aNULL:!MD5;
- ssl_prefer_server_ciphers on;
- location / {
- root html/SSLROOT;
- index index.html index.htm;
- # 开启白名单,根据需求替换
- allow 127.0.0.1;
- allow 192.168.11.10;
- deny all;
- #反向代理,根据需求替换
- proxy_pass http://192.168.11.10:9581;
- proxy_set_header Host $host;
- proxy_set_header X-Forwarded-For $remote_addr;
- }
- }
- }
参考:https://www.cnblogs.com/shihuc/p/7150900.html
基于openresty配置https访问的更多相关文章
- Linux Apache配置https访问
配置https访问 该环境是rh254课程配套的一个环境,不过配置方法步骤相同. 要求: 使用虚拟主机技术部署两个网站: 网站1: 绑定域名 www0.example.com 目录在 /srv/www ...
- OkHttp配置HTTPS访问+服务器部署
1 概述 OkHttp配置HTTPS访问,核心为以下三个部分: sslSocketFactory() HostnameVerifier X509TrustManager 第一个是ssl套接字工厂,第二 ...
- 使用docker搭建最新版本的gitea,并配置HTTPS访问
使用docker搭建最新版本的gitea,并配置HTTPS访问 博客说明 文章所涉及的资料来自互联网整理和个人总结,意在于个人学习和经验汇总,如有什么地方侵权,请联系本人删除,谢谢! 简介 之前有搭建 ...
- 基于openresty的https配置实践
最近机器人项目的子项目,由于和BAT中的一家进行合作,人家要求用HTTPS连接,于是乎,我们要改造我们的nginx的配置,加添HTTPS的支持. 当然了,HTTPS需要的证书,必须是认证机构颁发的,这 ...
- lamp之apache配置https访问
配置apache 使用https 注:怕其他人由于路径的原因出问题,首先声明一下,本人apache的安装目录为 : /usr/local/httpd2.4.25,如果不是,请参考进行配置 注: 对于如 ...
- nginx配置https访问
一.准备 环境:centos6.8 nginx:1.13.6 二.开始 首先安装依赖包: yum install -y gcc gcc-c++ autoconf automake make ...
- 本地测试Tomcat配置Https访问
一.tomcat开启HTTPS配置 1) 准备证书 使用jdk工具keytool生成一个ssl测试用证书, 一路按照提示操作输入即可 keytool -genkey -alias tomcat -ke ...
- Apache 配置 HTTPS访问
将需要配置的项目移动到另一根目录下,作为https访问位置. 修改bitnami配置文件..\Bitnami\wampstack-5.6.19-0\apache2\conf\bitnami\bitna ...
- 4-OpenResty 配置 https 访问
首先是下载证书 https://www.cnblogs.com/yangfengwu/p/11809757.html 因为咱用的 Nginx 所以 修改这个 server { listen ssl; ...
随机推荐
- TLB与内存寻址,内存读取,虚拟内存的相关原理
TLB(Translation Lookaside Buffer)转换检测缓冲区是一个内存管理单元,用于改进虚拟地址到物理地址转换速度的缓存. TLB是一个小的,虚拟寻址的缓存,其中每一行都保存着一个 ...
- boost之内存管理
内存管理一直是令C++程序员最头疼的工作,C++继承了C那高效而又灵活的指针,使用起来稍微不小心就会导致内存泄露.野指针.越界访问等访问.虽然C++标准提供了只能指针std::auto_ptr,但是并 ...
- 【记录】CentOS7安装NODEBB
NodeBB介绍: NodeBB 是一个更好的论坛平台,专门为现代网络打造.它是免费的,易于使用. NodeBB 论坛软件是基于 Node.js开发,支持 Redis 或 MongoDB 的数据库.它 ...
- js的prototype(2)
1 原型法设计模式 在.Net中可以使用clone()来实现原型法 原型法的主要思想是,现在有1个类A,我想要创建一个类B,这个类是以A为原型的,并且能进行扩展.我们称B的原型为A. 2 javasc ...
- firefox快速刷新error及解决办法
问题: 测试发过来bug,说——频繁F5刷新页面,会闪现未加载完样式的页面: 开发用的Chrome,没发现这个问题,测试用的firefox,于是从浏览器的刷新加载机制方面搜索解决办法,没搜到,运 ...
- 推送安霸A7L实时视频至RTMP服务器(1)
使用librtmp进行H264与AAC直播 (转:http://www.codeman.net/2014/01/439.html) 1.帧的划分 1.1 H.264帧 对于H.264而言每帧的界定符为 ...
- span和input同一行布局的时候,高度偏移解决方案
input标签或收盘标签 添加代码: vertical-align:top;
- Javascript 知识遗漏点梳理。
先说一下我之前学习Javascript的学习经历,然后就是最近几天学到以前没有注意的知识遗漏点. 1.之前的学习经历和方法: 最开始是看了Javascript DOM编程与艺术这本书,把慕课网上的&l ...
- jmeter 正则表达式
1.抓好请求,对着接口文档筛选好请求后,添加正则表达式 2.查看结果树,找到要提取的参数 3.书写正则 4.关联一下 5.直接跑一边就好,包成功,从数据库取的话,如果name:user,就直接参数化: ...
- [label][Node.js] Three content management systems base on Node.js
1. Keystonejs http://keystonejs.com/ 2. Apostrophe http://apostrophenow.org/