Nginx如何实现支持HTTPS协议详细说明

首选Tomcat此处省略,Nginx安装时的准备工作如下:

Nginx安装如下插件:

openssl-1.0.2 

pcre-8.21 

zlib-1.2.8

openssl安装时注意一些其他依赖插件如:

libcrypto.a  libcrypto.pc  libssl.a  libssl.pc

 

准备就绪之后,进行Nginx安装操作,Linux检测安装平台目标特征,执行命令:

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
 --with-http_realip_module --with-openssl=/usr/local/openssl-1.0.2 --with-zlib=/usr/local/zlib-1.2.8

 

Linux编译并安装命令,具体如下:

编译命令:make

安装命令:make install

清除编译命令:make clean 

 

生成秘钥文件,Linux下生成秘钥分别执行命令如下:

openssl genrsa -des3 -out ca.key 1024
openssl req -new -key ca.key -out ca.csr
cp ca.key ca.key.orgi
openssl rsa -in ca.key.orgi -out ca.key
openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt

 

参考参数说明:

Country Name (2 letter code)[XX]:cn--------国家

State or Province Name (full name)[]:yoodb---------省份

Locality Name (eg, city) [DefaultCity]:yoodb--------------地区名字

Organization Name (eg, company)[Default Company Ltd]:yoodb------公司名

Organizational Unit Name (eg,section) []:ning-----部门

Common Name (eg, your name or yourserver's hostname) []:yoodb----CA主机名

Email Address []:---------邮箱

 

Please enter the following 'extra'attributes

to be sent with your certificaterequest

A challenge password []:-----------证书请求密钥,CA读取证书的时候需要输入密码

An optional company name[]:-----------公司名称,CA读取证书的时候需要输入名称

 

Nginx配置nginx.conf文件,具体如下:

server {
        listen       443 ssl;
        server_name  blog.yoodb.com;
        ssl on;
        ssl_certificate /usr/local/nginx/conf/ssl/ca.crt;
        ssl_certificate_key /usr/local/nginx/conf/ssl/ca.key;
        ssl_session_timeout 5m;
        #    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
         #   ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
         #   ssl_prefer_server_ciphers on;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            proxy_pass   http://127.0.0.1:8081;
        }
        location /amserver {
            proxy_pass   http://127.0.0.1:8080;
        }
}

 

部署以及重启 Nginx 操作:

开启 Linux 端口号 443

iptables -A INPUT -p tcp --dport 443 -j ACCEPT

/etc/init.d/iptables status 查看防火墙状态

vim /etc/sysconfig/iptables 编辑防火墙文件

/etc/init.d/iptables restart 重启防火墙

nginx –s reload 重启 Nginx服务器命令

转载于:https://my.oschina.net/freelife/blog/831947

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值