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访问的更多相关文章

  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. LevelDB SSTable文件

    [LevelDB SSTable文件] LevelDb不同层级有很多SSTable文件(以后缀.sst为特征),所有.sst文件内部布局都是一样的.上节介绍Log文件是物理分块的,SSTable也一样 ...

  2. java并发特性:原子性、可见性、有序性

    要想并发程序正确地执行,必须要保证原子性.可见性以及有序性.只要有一个没有被保证,就有可能会导致程序运行不正确. 1.原子性(Atomicity) 原子性是指在一个操作中就是cpu不可以在中途暂停然后 ...

  3. PLSQL优化基础和性能优化 (学习总结)

    PLSQL优化基础和性能优化 (学习总结) 网上有一篇关于PLSQL优化的文章,不错,个人根据自己的经验再稍加整理和归纳,总结PLSQL优化和性能调优 适合有一定PLSQL基础,需要进一步提高的学友看 ...

  4. UITextFeild银行卡/身份证/电话号任意分割.

    日常开发中可能有个需求, 1.银行卡每4位添加一个空格  2.电话号:3 4 4 比如(138 8888 8888)3.身份证(411111 20171213 1314) 看了网上许多方法都是输入的时 ...

  5. Windows Python 2.7环境搭建

    一.安装及修改环境变量 我安装的版本是python-2.7.15.amd64,因为2.7.9之后的版本都会安装好pip.将Python执行文件所在文件夹加入path路径,C:\Python27.将pi ...

  6. 22-python爬虫解决gbk乱码问题

    转载自: python爬虫解决gbk乱码问题   今天尝试了下爬虫,爬取一本小说,忘语的凡人修仙仙界篇,当然这样不好,大家要支持正版. 爬取过程中是老套路,先获取网页源代码 # -*- coding: ...

  7. ToList和ToDataTable(其中也有反射的知识)

    using System;using System.Collections.Generic;using System.Data;using System.Linq;using System.Refle ...

  8. Oracle 11g PL/SQL Developer登入时候报ORA-12638: 身份证明检索失败的解决办法(安装了6遍,吐血之作)

    1.报这个错的时候会弹出一个对话框,先点击终止 2.然后汇报出这个是错误的窗口,然后点击确认,但是不要关这个安装窗口也不要其他不必要操作,窗口最小化 3.找到product文件夹,一般在app文件里 ...

  9. java.sql.SQLException: Access denied for user ''@'localhost' (using password: YES)

    这个问题是说明你的JDBC数据库连接位置出错了,请仔细检查 private static String url; private static String username; private sta ...

  10. sql语句语句中的正则查找

    举例: select tncl_id from tncl where tncl_id regexp'^0065'; 有一表,数据有10万多条,其中某列数据示例如下: 100000-200000-300 ...