Nginx安装HTTP SSL模块基本配置

摘要: 简单实现Nginx反向代理https请求的配置。

一、安装ssl和编译安装nginx

cd /opt/server/
wget 192.168.28.74:8080/openssl-1.0.2e.tar.gz
tar -xvf openssl-1.0.2e.tar.gz 
cd /opt/server/
wget http://mirrors.sohu.com/nginx/nginx-1.5.1.zip
unzip nginx-1.5.1.zip 

[root@bogon nginx-1.6.2]# ./configure  --prefix=/opt/server/nginx-1.5.1 --with-http_stub_status_module  --with-http_ssl_module --with-openssl=../openssl-1.0.2e/
[root@bogon nginx-1.6.2]# make
[root@bogon nginx-1.6.2]# make install

nginx默认安装在 /usr/local/目录下,这里指定安装在特定目录下

 

二、生成SSL证书

[root@bogon ssl]# openssl req -new -key junglone.com.key -out junglone.com.csr
Enter pass phrase for junglone.com.key:
You are about to be asked to enter information that will be incorporated
  to 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 (2 letter code) [XX]:CN
State or Province Name (full name) []:China
Locality Name (eg, city) [Default City]:Beijing
Organization Name (eg, company) [Default Company Ltd]:junglone.com
Organizational Unit Name (eg, section) []:junglone.com
Common Name (eg, your name or your server's hostname) []:junglone.com
Email Address []:admin@junglone.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[root@bogon ssl]# openssl rsa -in junglone.com.key -out junglone.com_nopass.key
Enter pass phrase for junglone.com.key:
writing RSA key
[root@bogon ssl]# ls
junglone.com.csr  junglone.com.key  junglone.com_nopass.key
[root@bogon ssl]# ll
总用量 12
-rw-r--r-- 1 root root 716 722 13:17 junglone.com.csr
-rw-r--r-- 1 root root 891 722 13:18 junglone.com.key
-rw-r--r-- 1 root root 963 722 13:17 junglone.com_nopass.key
[root@bogon ssl]#

按照以上方式自行颁发的SSL证书是不受浏览器信任的。推荐使用受浏览器信任的StartSSL免费SSL证书。

申请地址:https://startssl.com

 

三、Nginx配置

    server {
        listen       443 ssl;
        server_name  localhost;

        ssl on;

        ssl_certificate /usr/local/nginx/ssl/1_junglone.com_bundle.crt;
        ssl_certificate_key /usr/local/nginx/ssl/junglone.com_nopass.key;
	ssl_session_timeout  30m;
        ssl_protocols  SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:!EXP:!RC4:!MD5:!DES:!aNull;
        ssl_prefer_server_ciphers   on;
        location / {
            root   html;
            index  index.html index.htm;
        }
    }

 

四、验证

因为证书颁发给的是junglone.com,所以通过ip访问的时候是有安全提醒。

通过域名访问就可以看到清爽的小图标了。如下图:

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值