1. openssl的版本信息

  1. [root@localhost conf]# openssl version
  2. OpenSSL 1.0.1e-fips 11 Feb 2013

2. openresty的版本信息

  1. [root@localhost sbin]# ./nginx -V
  2.  

3. 创建服务器私钥,命令会提醒输入一个密码,必须输入(在nginx的conf所在的路径下进行操作,当然也可以在其他路径,需要配合后续的nginx的配置一起改变

  1. [root@localhost conf]# openssl genrsa -des3 -out server.key
  2. Generating RSA private key, bit long modulus
  3. ..............................................................++
  4. ........................++
  5. e is (0x10001)
  6. Enter pass phrase for server.key:
  7. :error::lib():UI_set_result:result too small:ui_lib.c::You must type in to characters
  8. Enter pass phrase for server.key:
  9. :error::lib():UI_set_result:result too small:ui_lib.c::You must type in to characters
  10. Enter pass phrase for server.key:
  11. Verifying - Enter pass phrase for server.key:
  12. [root@localhost conf]# ll
  13. 总用量
  14. -rw-r--r--. root root 3 : fastcgi.conf
  15. -rw-r--r--. root root 3 : fastcgi.conf.default
  16. -rw-r--r--. root root 3 : fastcgi_params
  17. -rw-r--r--. root root 3 : fastcgi_params.default
  18. -rw-r--r--. root root 3 : koi-utf
  19. -rw-r--r--. root root 3 : koi-win
  20. -rw-r--r--. root root 3 : mime.types
  21. -rw-r--r--. root root 3 : mime.types.default
  22. -rw-r--r--. root root 3 : nginx.conf
  23. -rw-r--r--. root root 3 : nginx.conf.default
  24. -rw-r--r--. root root 3 : scgi_params
  25. -rw-r--r--. root root 3 : scgi_params.default
  26. -rw-r--r-- root root 7 : server.key
  27. -rw-r--r--. root root 3 : uwsgi_params
  28. -rw-r--r--. root root 3 : uwsgi_params.default
  29. -rw-r--r--. root root 3 : win-utf

4. 创建签名请求的证书(CSR)

  1. [root@localhost conf]# openssl req -new -key server.key -out server.csr
  2. Enter pass phrase for server.key:
  3. You are about to be asked to enter information that will be incorporated
  4. into your certificate request.
  5. What you are about to enter is what is called a Distinguished Name or a DN.
  6. There are quite a few fields but you can leave some blank
  7. For some fields there will be a default value,
  8. If you enter '.', the field will be left blank.
  9. -----
  10. Country Name ( letter code) [XX]:cn
  11. State or Province Name (full name) []:hubei
  12. Locality Name (eg, city) [Default City]:wuhan
  13. Organization Name (eg, company) [Default Company Ltd]:tk
  14. Organizational Unit Name (eg, section) []:iflab
  15. Common Name (eg, your name or your server's hostname) []:root
  16. Email Address []:shihuc@.com
  17.  
  18. Please enter the following 'extra' attributes
  19. to be sent with your certificate request
  20. A challenge password []:shihuc
  21. An optional company name []:tk
  22. [root@localhost conf]#

5. 在加载SSL支持的Nginx服务器上,使用上述私钥时除去必须的口令(注意,所谓除去,其实就是将必须的私钥密码写入到了私钥文件里面了,更新了原来的私钥文件)

  1. [root@localhost conf]# cp server.key server.key.org
  2. [root@localhost conf]#
  3. [root@localhost conf]# openssl rsa -in server.key.org -out server.key
  4. Enter pass phrase for server.key.org:
  5. writing RSA key
  6. [root@localhost conf]#

6. 通过openssl的x509指令生产证书文件

  1. [root@localhost conf]# openssl x509 -req -days -in server.csr -signkey server.key -out server.crt
  2. Signature ok
  3. subject=/C=cn/ST=hubei/L=wuhan/O=tk/OU=iflab/CN=root/emailAddress=shihuc@.com
  4. Getting Private key

7. nginx的简单配置

  1. # HTTPS server
  2. #
  3. server {
  4. listen ssl;
  5. server_name localhost;
  6.  
  7. ssl_certificate server.crt;
  8. ssl_certificate_key server.key;
  9.  
  10. ssl_session_cache shared:SSL:1m;
  11. ssl_session_timeout 5m;
  12.  
  13. ssl_ciphers HIGH:!aNULL:!MD5;
  14. ssl_prefer_server_ciphers on;
  15.  
  16. location / {
  17. root html/SSLROOT;
  18. index index.html index.htm;
  19. }
  20. }

在nginx的html目录下,创建SSLROOT目录,并在下面创建一个index.html的页面,用于测试。

8. 一个用于转发的nginx.conf文件

  1. worker_processes ;
  2. error_log logs/error.log;
  3. events {
  4. worker_connections ;
  5. }
  6.  
  7. http {
  8. keepalive_timeout ;
  9. sendfile on;
  10.  
  11. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  12. '$status $body_bytes_sent "$http_referer" '
  13. '"$http_user_agent" "$http_x_forwarded_for"';
  14.  
  15. server {
  16. listen ssl;
  17. # listen ssl;
  18. server_name localhost;
  19.  
  20. ssl_certificate kaili.axinfu.com.crt;
  21. ssl_certificate_key kaili.axinfu.com.key;
  22.  
  23. ssl_session_cache shared:SSL:1m;
  24. ssl_session_timeout 5m;
  25.  
  26. ssl_ciphers HIGH:!aNULL:!MD5;
  27. ssl_prefer_server_ciphers on;
  28.  
  29. location / {
  30. root html/SSLROOT;
  31. index index.html index.htm;
  32. # 开启白名单,根据需求替换
  33. allow 127.0.0.1;
  34. allow 192.168.11.10;
  35. deny all;
  36.  
  37. #反向代理,根据需求替换
  38. proxy_pass http://192.168.11.10:9581;
  39. proxy_set_header Host $host;
  40. proxy_set_header X-Forwarded-For $remote_addr;
  41. }
  42. }
  43. }

参考:https://www.cnblogs.com/shihuc/p/7150900.html

基于openresty配置https访问的更多相关文章

  1. Linux Apache配置https访问

    配置https访问 该环境是rh254课程配套的一个环境,不过配置方法步骤相同. 要求: 使用虚拟主机技术部署两个网站: 网站1: 绑定域名 www0.example.com 目录在 /srv/www ...

  2. OkHttp配置HTTPS访问+服务器部署

    1 概述 OkHttp配置HTTPS访问,核心为以下三个部分: sslSocketFactory() HostnameVerifier X509TrustManager 第一个是ssl套接字工厂,第二 ...

  3. 使用docker搭建最新版本的gitea,并配置HTTPS访问

    使用docker搭建最新版本的gitea,并配置HTTPS访问 博客说明 文章所涉及的资料来自互联网整理和个人总结,意在于个人学习和经验汇总,如有什么地方侵权,请联系本人删除,谢谢! 简介 之前有搭建 ...

  4. 基于openresty的https配置实践

    最近机器人项目的子项目,由于和BAT中的一家进行合作,人家要求用HTTPS连接,于是乎,我们要改造我们的nginx的配置,加添HTTPS的支持. 当然了,HTTPS需要的证书,必须是认证机构颁发的,这 ...

  5. lamp之apache配置https访问

    配置apache 使用https 注:怕其他人由于路径的原因出问题,首先声明一下,本人apache的安装目录为 : /usr/local/httpd2.4.25,如果不是,请参考进行配置 注: 对于如 ...

  6. nginx配置https访问

    一.准备 环境:centos6.8 nginx:1.13.6 二.开始       首先安装依赖包: yum install -y gcc gcc-c++ autoconf automake make ...

  7. 本地测试Tomcat配置Https访问

    一.tomcat开启HTTPS配置 1) 准备证书 使用jdk工具keytool生成一个ssl测试用证书, 一路按照提示操作输入即可 keytool -genkey -alias tomcat -ke ...

  8. Apache 配置 HTTPS访问

    将需要配置的项目移动到另一根目录下,作为https访问位置. 修改bitnami配置文件..\Bitnami\wampstack-5.6.19-0\apache2\conf\bitnami\bitna ...

  9. 4-OpenResty 配置 https 访问

    首先是下载证书  https://www.cnblogs.com/yangfengwu/p/11809757.html 因为咱用的 Nginx 所以 修改这个 server { listen ssl; ...

随机推荐

  1. TLB与内存寻址,内存读取,虚拟内存的相关原理

    TLB(Translation Lookaside Buffer)转换检测缓冲区是一个内存管理单元,用于改进虚拟地址到物理地址转换速度的缓存. TLB是一个小的,虚拟寻址的缓存,其中每一行都保存着一个 ...

  2. boost之内存管理

    内存管理一直是令C++程序员最头疼的工作,C++继承了C那高效而又灵活的指针,使用起来稍微不小心就会导致内存泄露.野指针.越界访问等访问.虽然C++标准提供了只能指针std::auto_ptr,但是并 ...

  3. 【记录】CentOS7安装NODEBB

    NodeBB介绍: NodeBB 是一个更好的论坛平台,专门为现代网络打造.它是免费的,易于使用. NodeBB 论坛软件是基于 Node.js开发,支持 Redis 或 MongoDB 的数据库.它 ...

  4. js的prototype(2)

    1 原型法设计模式 在.Net中可以使用clone()来实现原型法 原型法的主要思想是,现在有1个类A,我想要创建一个类B,这个类是以A为原型的,并且能进行扩展.我们称B的原型为A. 2 javasc ...

  5. firefox快速刷新error及解决办法

    问题: 测试发过来bug,说——频繁F5刷新页面,会闪现未加载完样式的页面:    开发用的Chrome,没发现这个问题,测试用的firefox,于是从浏览器的刷新加载机制方面搜索解决办法,没搜到,运 ...

  6. 推送安霸A7L实时视频至RTMP服务器(1)

    使用librtmp进行H264与AAC直播 (转:http://www.codeman.net/2014/01/439.html) 1.帧的划分 1.1 H.264帧 对于H.264而言每帧的界定符为 ...

  7. span和input同一行布局的时候,高度偏移解决方案

    input标签或收盘标签 添加代码: vertical-align:top;

  8. Javascript 知识遗漏点梳理。

    先说一下我之前学习Javascript的学习经历,然后就是最近几天学到以前没有注意的知识遗漏点. 1.之前的学习经历和方法: 最开始是看了Javascript DOM编程与艺术这本书,把慕课网上的&l ...

  9. jmeter 正则表达式

    1.抓好请求,对着接口文档筛选好请求后,添加正则表达式 2.查看结果树,找到要提取的参数 3.书写正则 4.关联一下 5.直接跑一边就好,包成功,从数据库取的话,如果name:user,就直接参数化: ...

  10. [label][Node.js] Three content management systems base on Node.js

    1. Keystonejs http://keystonejs.com/ 2. Apostrophe http://apostrophenow.org/