nginx + tomcat + https 配置

一:nginx 配置https

(1)#生成私钥

#openssl genrsa -des3 -out server.key 1024

(2)#生成证书请求文件

     #openssl req -new -key server.key -out server.csr

输出内容为:
Enter pass phrase for root.key: ← 输入前面创建的密码
Country Name (2 letter code) [AU]:CN ← 国家代号,中国输入CN
State or Province Name (full name) [Some-State]:BeiJing ← 省的全名,拼音
Locality Name (eg, city) []:BeiJing ← 市的全名,拼音
Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyCompany Corp. ← 公司英文名
Organizational Unit Name (eg, section) []: ← 可以不输入
Common Name (eg, YOUR name) []: ← 此时不输入
Email Address []:[email protected] ← 电子邮箱,可随意填
Please enter the following ‘extra’ attributes
to be sent with your certificate request
A challenge password []: ← 可以不输入
An optional company name []: ← 可以不输入

(3)在加载SSL支持的Nginx并使用上述私钥时除去必须的口令:

 #cp server.key server.key.org

 # openssl rsa -in server.key.org -out server.key

(4)最后标记证书使用上述私钥和CSR:

#openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

-new: 生成新证书签署请求
-x509: 专用于CA生成自签证书
-key: 生成请求时用到的私钥文件
-days n:证书的有效期限,单位是day,默认是365天
-out /PATH/TO/SOMECERTFILE: 证书的保存路径

(5)配置nginx

server {

      listen       443;   #指定ssl监听端口

      server_name  www.example.com;

      ssl on;    #开启ssl支持

      ssl_certificate      /etc/nginx/server.pem;    #指定服务器证书路径

      ssl_certificate_key  /etc/nginx/server.key;    #指定私钥证书路径

      ssl_session_timeout  5m;

      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;     #指定SSL服务器端支持的协议版本

      ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;    #指定加密算法

      ssl_prefer_server_ciphers   on;    #在使用SSLv3和TLS协议时指定服务器的加密算法要优先于客户端的加密算法

# 

    location / {

        #配置忽略

      }

}

二:tomcat

  (1)创建秘钥库

     # keytool -genkey -alias tomcat -keyalg RSA -keystore   /home/liuge/cert/mykey.keystore

nter keystore password: 输入秘钥库口令
Re-enter new password: 再次输入新口令
What is your first and last name? 您的姓氏是什么
[Unknown]: Tomcat
What is the name of your organizational unit? 您的单位名称
[Unknown]: Apache
What is the name of your organization? 您的组织名称
[Unknown]: Apache
What is the name of your City or Locality?省份
[Unknown]: Beijing
What is the name of your State or Province?城市
[Unknown]: Beijing
What is the two-letter country code for this unit? 国家代码
 [Unknown]: CN
Is CN=Tomcat, OU=Apache, O=Apache, L=Beijing, ST=Beijing, C=CN correct? 信息是否正确
[no]: y
  
Enter key password for                 输入Tomcat的秘钥口令
(RETURN if same as keystore password): 如果和秘钥库口令相同,按回车
 Re-enter new password:

2 配置server.xml文件


    
      
    

 

你可能感兴趣的:(集群)