基于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; ...
随机推荐
- windchill StatementCache: wt.util.Cache%828007782 [size=50, count=4, hits=36, misses=4, aged=0]
StatementCache: wt.util.Cache%828007782 [size=50, count=4, hits=36, misses=4, aged=0] 方法: EXEC sys.s ...
- synchronized的简单理解
synchronized能够保证在同一时刻只有一个线程执行该段代码. 使用synchronized能够防止多个线程同时并发访问程序的某些资源. synchronized既可以修饰变量,也可以修饰方法, ...
- 【bzoj3437】小P的牧场
3437: 小P的牧场 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 947 Solved: 542[Submit][Status][Discuss ...
- Vue SPA应用中使用Layer的iframe 弹出层,并且传值
问题来源: BOOS 竟然说喜欢有可移动可最大化的弹出层,这!!! SPA 模式下就是这种引入Vue.js的写法 layer.open({ type: , area: ['840px', '550px ...
- php中++i 与 i++ 的区分详解
在编程时我们常会使用到i++和++i,那两者之间有什么区别呢,本教程就为大家详细介绍一下. 1.++i 的用法(以 a=++i ,i=2 为例) 先将 i 值加 1 (也就是 i=i+1 ),然后赋给 ...
- embed jetty lib
servlet-api-3.1.jar jetty-util-9.2.2.v20140723.jar jetty-servlet-9.2.2.v20140723.jar jetty-server-9. ...
- NormalMap原理详细解析
NormalMap的实现标志着对渲染流水线的各个环节以及矩阵变化有了正确和深入的认识.这里记录一下学习过程,以及关于NormalMap的诸多细节. 刚开始想要实现NormalMap程序的时候,查阅的是 ...
- jquery的理解
1.jquery的好处 简化js的复杂操作 不再需要关心兼容性 提供大量使用方法 2.jquery的设计思想 选择网页元素 -模拟css选择元素 -独有的表达式选择 -多种筛选方法 写法 -方法函数化 ...
- Word直接发布新浪博客(以Word 2010为例)
目前大部分的博客作者在用Word写博客这件事情上都会遇到以下3个痛点: 1.所有博客平台关闭了文档发布接口,用户无法使用Word,Windows Live Writer等工具来发布博客.使用Word写 ...
- VMware安装Ubuntu
1. VMware Ubuntu安装详细过程:http://blog.csdn.net/u013142781/article/details/50529030 2. 怎样在VMware虚拟机中使用安装 ...