centos的nginx支持ssl
首先看centos是否支持ssl
输入:openssl version
如无
则去 http://slproweb.com/products/Win32OpenSSL.html 寻找

生成私钥后面的1024可加密128字节长度的内容,2048可加密256字节长度的内容
对应的命令如下:
在ssl的根目录下操作: #此步用于生成私钥,会提示输入密码,密码后面步骤需要用到;jason.key为私钥的名字,文件名可自己定
openssl genrsa -des3 -out jason.key 1024 #此步用于生成csr证书,jason.key为上一步骤生成的私钥名,jason.csr为证书,证书文件名可自定
#在此步过程中,会交互式输入一系列的信息(所在国家、城市、组织等),其中Common Name一项代表nginx服务访问用到的域名,我这里是本地测试,所以可以随意定一个jason.com,并在本地host文件中将此域名映射为127.0.0.1
openssl req -new -key jason.key -out jason.csr #此步用于去除访问密码,如果不执行此步,在配置了ssl后,nginx启动会要求输入密码
#jason.key为需要密码的key,jason-np.key为去除访问密码的key文件
#操作过程中会要求输入密码,密码为生成key文件时的密码
openssl rsa -in jason.key -out jason-np.key #此步用于生成crt证书
#jason.crt为第2步生成的csr证书名称,jason.crt为要生成的证书名称
openssl x509 -req -days 366 -in jason.csr -signkey jason-np.key -out jason.crt
输入国家系列信息:

server {
listen 443 ssl;
server_name service.youhui168.xin;
ssl on;
ssl_certificate ../ssl/shopService.crt;
ssl_certificate_key ../ssl/shopService-np.key;
#ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
#ssl_ciphers HIGH:!aNULL:!MD5;
#ssl_prefer_server_ciphers on;
error_log /usr/local/nginx/logs/error2.log error;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080/service/;
}
}
注意阿里云里面要配置好对应的入方向的443的端口规则
http://localhost:8080/service/ 对应的是tomcat启动的那个service项目 如此,https访问成功 如还不成,应该是服务器的防火墙问题了:netstat -anp查看防火墙开的端口
发现已经在监听了,那肯定是配置问题。
检查配置没问题,重新生成证书等方法也还是无法访问,甚至在别的机器上https的配置copy过来依然无法访问
冷静下来想想,nginx都没有返回状态吗,直接无法连接。这到底请求到了吗?
只能进入防火墙配置文件看看了 vim /etc/sysconfig/iptables

问题就在这里了,开放端口一定要在
-A INPUT -j REJECT –reject-with icmp-host-prohibited
这句的前面,的前面,的前面!!!
原因是这条规则的作用是拒绝所有-j REJECT 在iptables帮助文档里面有一下说明This is used to send back an error packet in response to the matched packet
就是表明拒绝你,并返回一个错误连接信息。请求没到nginx那,肯定没有状态码返回,同时你的浏览器返回的只能是无法连接。
===============================================================
另一个test例子
证书同上配置
nginx的配置是:
server {
listen 443 ssl;
server_name test.youhui168.xin;
ssl_certificate ../ssl/test.crt;
ssl_certificate_key ../ssl/test-np.key;
#ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:80/;
}
}
server {
listen 80;
server_name test.youhui168.xin;
root /home/wwwroot/test;
index index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE open_basedir=$document_root:/tmp/:/proc/;
include fastcgi_params;
}
}
如此,https访问成功
centos的nginx支持ssl的更多相关文章
- nginx支持ssl双向认证配置
nginx支持ssl双向认证配置 listen 443; server_name test.com; ssl on; ssl_certificate server.crt; //server端公钥 s ...
- 配置Nginx支持SSL SNI(一个IP绑定多个证书) 以及Haproxy实现多域名证书
概述 传统的每个SSL证书签发,每个证书都需要独立ip,假如你编译openssl和nginx时候开启TLS SNI (Server Name Identification) 支持,这样你可以安装多个S ...
- Centos下nginx支持https协议
1.首先配置nginx及其他插件,这个Google下,很多配置方案. 2.配置服务器的证书.操作步骤如下: [root@localhost ~]# cd /etc/pki/tls/certs [roo ...
- CentOS 6.7 配置nginx支持SSL/https访问
一.安装必要的包 yum install openssl openssl-devel 二.配置编译参数,增加对SSL的支持 ./configure –with-http_ssl_module 三.修改 ...
- 配置nginx支持ssl服务器—HTTPS
下文摘自: http://docs.bigbluebutton.org/install/install.html Configuring HTTPS on BigBlueButtonAncho ...
- 最简单的dockerfile使用教程 - 创建一个支持SSL的Nginx镜像
什么是dockerfile?简单的说就是一个文本格式的脚本文件,其内包含了一条条的指令(Instruction),每一条指令负责描述镜像的当前层(Layer)如何构建. 下面通过一个具体的例子来学习d ...
- Nginx server之Nginx添加ssl支持
//环境介绍 1.nginx服务器:10.10.54.157 2.配置nginx服务器,当监听到来自客户端www.zijian.com:80请求时,转到10.10.54.150:1500这个web服务 ...
- nginx https ssl 设置受信任证书[原创]
1. 安装nginx 支持ssl模块 http://nginx.org/en/docs/configure.html yum -y install openssh openssh-devel (htt ...
- nginx https ssl 设置受信任证书[转然哥]
nginx https ssl 设置受信任证书[原创] 1. 安装nginx 支持ssl模块 http://nginx.org/en/docs/configure.html yum -y instal ...
随机推荐
- Domoticz 中添加彩云天气
前言 用过一段时间的彩云天气 APP,最吸引我的地方是精确到局部区域的天气预测,虽然准确度并不算高,但是对于预测下雨还是不错的选择.在 Domoticz 中添加彩云天气的数据,利用的是彩云天气提供的 ...
- HTML 5 桌面提醒
<script> function showNotice(title,msg){ var Notification = window.Notification || window.mozN ...
- Little Elephant and Magic Square
Little Elephant loves magic squares very much. A magic square is a 3 × 3 table, each cell contains s ...
- R语言学习笔记(四)
6. 数据转换 本章主要讲述apply系列函数:apply.lapply.sapply.tapply.mapply,以及姊妹函数by.split.适用于批量处理数据,而不许循环. 6.1 向量分组 用 ...
- C++_异常7-exception类
C++异常的主要目的是为了设计容错程序提供语言级支持. 即异常使得在程序设计中包含错误处理功能更加容易,以免事后采取一些严格的错误处理方式. 异常的灵活性和相对方便性激励着程序员在条件允许的情况下在程 ...
- A Simple Math Problem(矩阵快速幂)----------------------蓝桥备战系列
Lele now is thinking about a simple function f(x). If x < 10 f(x) = x. If x >= 10 f(x) = a0 ...
- pandas to_excel、to_csv的float_format参数设置
df.to_excel(outpath,float_format='%.2f')
- Oracle broker--详解
1,简介 01,介绍 Data Guard broker是建立在Data Guard基础上的一个对Data Guard配置,集中管理操作的一个平台.我们再上次DG主备切换的时候会发现特别麻烦,为此br ...
- opengl键盘回调函数不能获取Ctrl+c的问题
我要令窗口在按下 Ctrl+c 之后关闭. 关键代码如下: /* 这段代码位于键盘回调函数中 */ if ((glutGetModifiers() == GLUT_ACTIVE_CTRL) & ...
- TOJ 4002 Palindrome Generator
描述 A palindrome is a number that reads the same whether you read it from left to right or from right ...
