https和server-status配置案例
https和server-status配置案例
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
[root@yinzhengjie ~]# more /etc/pki/tls/openssl.cnf | grep countryName_default
#countryName_default = XX
countryName_default = CN ------>修改国家名字为中国
[root@yinzhengjie ~]#
[root@yinzhengjie ~]# more /etc/pki/tls/openssl.cnf | grep stateOrProvinceName_default
#stateOrProvinceName_default = Default Province
stateOrProvinceName_default = BeiJing ------->修改省份为北京
[root@yinzhengjie ~]#
[root@yinzhengjie ~]# more /etc/pki/tls/openssl.cnf | grep localityName_default
#localityName_default = Default City
localityName_default = Yizhuang Economic Development Zone ----->修改所在区域
[root@yinzhengjie ~]#
[root@yinzhengjie ~]# more /etc/pki/tls/openssl.cnf | grep .organizationName_default
#.organizationName_default = Default Company Ltd
.organizationName_default = Chinese Academy of Medical Sciences ---->修改你所在的单位
[root@yinzhengjie ~]#
[root@yinzhengjie ~]#
[root@yinzhengjie ~]# more /etc/pki/tls/openssl.cnf | grep organizationalUnitName_default
#organizationalUnitName_default = World Wide Web Pty Ltd
organizationalUnitName_default = LinuxOperation ------>修改你担任的职位
[root@yinzhengjie ~]#
[root@yinzhengjie CA]# openssl req -new -x509 -key private/cakey.pem -days -out cacert.pem
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) [CN]:
State or Province Name (full name) [BeiJing]:
Locality Name (eg, city) [Yizhuang Economic Development Zone]:
Organization Name (eg, company) [Chinese Academy of Medical Sciences]:
Organizational Unit Name (eg, section) [LinuxOperation]:
Common Name (eg, your name or your server's hostname) []:ca.yinzhengjie.org.cn
Email Address []:caadmin@yinzhengjie.org.cn
You have new mail in /var/spool/mail/root
[root@yinzhengjie CA]#
[root@yinzhengjie CA]# ls
cacert.pem certs crl newcerts private
[root@yinzhengjie CA]#
[root@yinzhengjie CA]# touch index.txt serial crlnumber
[root@yinzhengjie CA]# echo > serial
[root@yinzhengjie CA]# ls
cacert.pem certs crl crlnumber index.txt newcerts private serial
[root@yinzhengjie CA]#
[root@yinzhengjie ~]# cd /etc/httpd/conf
[root@yinzhengjie conf]#
[root@yinzhengjie conf]# mkdir ssl
[root@yinzhengjie conf]# cd ssl/
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# (umask ;openssl genrsa > http.key) ----生成服务器的私钥
Generating RSA private key, bit long modulus
..........++++++
...++++++
e is (0x10001)
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# ll
total
-rw-------. root root Oct : http.key
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# openssl req -new -key http.key -out httpd.csr
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) [CN]:
State or Province Name (full name) [BeiJing]:
Locality Name (eg, city) [Yizhuang Economic Development Zone]:
Organization Name (eg, company) [Chinese Academy of Medical Sciences]:
Organizational Unit Name (eg, section) [LinuxOperation]:
Common Name (eg, your name or your server's hostname) []:www.yinzhengjie.org.cn
Email Address []:webadmin@yinzhengjie.org.cn Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: ------>此处的密码可以设置为空,直接回车即可。
An optional company name []:
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# ll
total
-rw-r--r--. root root Oct : httpd.csr
-rw-------. root root Oct : http.key
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# openssl ca -in httpd.csr -out httpd.crt ----->进行CA签名生成一个证书。
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: (0x2)
Validity
Not Before: Oct :: GMT
Not After : Oct :: GMT
Subject:
countryName = CN
stateOrProvinceName = BeiJing
organizationName = Chinese Academy of Medical Sciences
organizationalUnitName = LinuxOperation
commonName = www.yinzhengjie.org.cn
emailAddress = webadmin@yinzhengjie.org.cn
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
::A0::0C:2C:FB:::9D:E8:D7:1D:B5:::F7:E5::6A
X509v3 Authority Key Identifier:
keyid:3E:ED:2C::AF:F5:::::E7:8F:::0B::4C:ED::4B Certificate is to be certified until Oct :: GMT ( days)
Sign the certificate? [y/n]:y out of certificate requests certified, commit? [y/n]y
Write out database with new entries
Data Base Updated
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# ll
total
-rw-r--r--. root root Oct : httpd.crt
-rw-r--r--. root root Oct : httpd.csr
-rw-------. root root Oct : http.key
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# grep mod_ssl /etc/httpd/conf/httpd.conf ---->查看是否已经安装mod_ssl模块。
# (e.g. :) if mod_ssl is being used, due to the nature of the
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# grep mod_ssl /etc/httpd/conf.d/*.conf ----->去子目录也查一遍;
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# yum -y install mod_ssl ----->安装mod_ssl模块;
[root@yinzhengjie ssl]# rpm -ql mod_ssl ------>查mod_ssl安装的文件;
/etc/httpd/conf.d/ssl.conf
/usr/lib64/httpd/modules/mod_ssl.so
/var/cache/mod_ssl
/var/cache/mod_ssl/scache.dir
/var/cache/mod_ssl/scache.pag
/var/cache/mod_ssl/scache.sem
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# more /etc/httpd/conf.d/ssl.conf | grep DocumentRoot
DocumentRoot "/var/www/html" ---->设置网站的根目录
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# more /etc/httpd/conf.d/ssl.conf | grep ServerName
ServerName www.yinzhengjie.org.cn: ------>设置主机名
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# more /etc/httpd/conf.d/ssl.conf | grep ErrorLog
ErrorLog logs/ssl_error_log ------->定义错误日志路径
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# more /etc/httpd/conf.d/ssl.conf | grep TransferLog
TransferLog logs/ssl_access_log ------->定义访问日志路径,注意,由于https是二进制格式的协议,因此和httpd的主配置文件定义访问日志的指令是不一样的哟
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# more /etc/httpd/conf.d/ssl.conf | grep LogLevel | grep -v ^#
LogLevel warn --------->定义日志级别
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# more /etc/httpd/conf.d/ssl.conf | grep SSLEngine
SSLEngine on --------->将SSL功能开启,启用基于SSL的虚拟主机;
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# more /etc/httpd/conf.d/ssl.conf | grep SSLProtocol
SSLProtocol all -SSLv2 ---------->表示支持所有的SSL协议,处理-SSLv2版本,换句话说它就只剩下-SSLv3以及TLSv1啦。
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# more /etc/httpd/conf.d/ssl.conf | grep SSLCipherSuite
SSLCipherSuite DEFAULT:!EXP:!SSLv2:!DES:!IDEA:!SEED:+3DES ------>指定SSL的加密套件,注意,感叹号(!)表示不支持的算法,加号(+)表示支持加密算法。
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# more /etc/httpd/conf.d/ssl.conf | grep SSLCertificateFile | grep -v ^#
SSLCertificateFile /etc/httpd/conf/ssl/httpd.crt ------>指定WEB服务器端证书
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# more /etc/httpd/conf.d/ssl.conf | grep SSLCertificateKeyFile
SSLCertificateKeyFile /etc/httpd/conf/ssl/http.key ------->指定WEB服务器的私钥
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# httpd -t ---------->检查配置是否正确
httpd: apr_sockaddr_info_get() failed for yinzhengjie
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Syntax OK -------->说明语法配置无误!
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# service httpd restart ------->重启web服务。
Stopping httpd: [ OK ]
Starting httpd: httpd: apr_sockaddr_info_get() failed for yinzhengjie
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[ OK ]
[root@yinzhengjie ssl]#
[root@yinzhengjie ssl]# ss -tnl | grep ------->查看443端口是否正常监听
LISTEN ::: :::*
[root@yinzhengjie ssl]#
[root@yinzhengjie ~]# openssl s_client -connect www.yinzhengjie.org.cn: -CAfile /etc/pki/CA/cacert.pem ------->我们可以基于本地的命令行进行测试。当然也可以在客户端的浏览器测试,只不过需要安装证书。
[root@yinzhengjie ~]#









[root@yinzhengjie certs]# pwd
/etc/pki/tls/certs
[root@yinzhengjie certs]# make yinzhengjie.key
umask ; \
/usr/bin/openssl genrsa -aes128 > yinzhengjie.key
Generating RSA private key, bit long modulus
........................+++
.......................................................................................+++
e is (0x10001)
Enter pass phrase: ------>要求你输入密码,这里是强制你输入密码,不能为空!
Verifying - Enter pass phrase: ------>要求你重复上次输入的密码
[root@yinzhengjie certs]#
[root@yinzhengjie certs]# ll
total
-rw-r--r--. root root Jul ca-bundle.crt
-rw-r--r--. root root Jul ca-bundle.trust.crt
-rwxr-xr-x. root root Oct make-dummy-cert
-rw-r--r--. root root Oct Makefile
-rwxr-xr-x. root root Oct renew-dummy-cert
-rw-------. root root Oct : yinzhengjie.key
[root@yinzhengjie certs]#
[root@yinzhengjie certs]# make yinzhengjie.pem
umask ; \
PEM1=`/bin/mktemp /tmp/openssl.XXXXXX` ; \
PEM2=`/bin/mktemp /tmp/openssl.XXXXXX` ; \
/usr/bin/openssl req -utf8 -newkey rsa: -keyout $PEM1 -nodes -x509 -days -out $PEM2 -set_serial ; \
cat $PEM1 > yinzhengjie.pem ; \
echo "" >> yinzhengjie.pem ; \
cat $PEM2 >> yinzhengjie.pem ; \
rm -f $PEM1 $PEM2
Generating a bit RSA private key
..+++
......................................................................+++
writing new private key to '/tmp/openssl.Ra7W2f'
-----
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]: ------->一路回车即可,我们这里只是测试。
State or Province Name (full name) []:
Locality Name (eg, city) [Default City]:
Organization Name (eg, company) [Default Company Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []:
Email Address []:
You have new mail in /var/spool/mail/root
[root@yinzhengjie certs]#
具体的配置参数可参考:
<Location /server-status>
SetHandler server-status
AuthType Basic
AuthName "Sever Status"
AuthUserFile /etc/httpd/conf/.ApachePassword
Require valid-user
Order deny,allow
Allow from all
</Location>

https和server-status配置案例的更多相关文章
- tomcat支持https的server.xml配置
访问地址:https://127.0.0.1/testWeb/mySevlet?url=123&action=aaa server.xml: <?xml version='1.0' en ...
- Httpd服务入门知识-Httpd服务常见配置案例之Apache的工作做状态status页面
Httpd服务入门知识-Httpd服务常见配置案例之Apache的工作做状态status页面 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.status功能概述 status页 ...
- Httpd服务入门知识-Httpd服务常见配置案例之定义'Main' server的文档页面路径(文档根路径)
Httpd服务入门知识-Httpd服务常见配置案例之定义'Main' server的文档页面路径(文档根路径) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.创建测试文件 [ ...
- 使用mysql存放Ambari元数据的配置案例
使用mysql存放Ambari元数据的配置案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.环境准备 详情请参考我之前的笔记:离线方式部署Ambari2.6.0.0 中关 ...
- Nginx插件之openresty反向代理和日志滚动配置案例
Nginx插件之openresty反向代理和日志滚动配置案例 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.openresty介绍 1>.Nginx介绍 Nginx是一款 ...
- springboot配置server相关配置&整合模板引擎Freemarker、thymeleaf&thymeleaf基本用法&thymeleaf 获取项目路径 contextPath 与取session中信息
1.Springboot配置server相关配置(包括默认tomcat的相关配置) 下面的配置也都是模板,需要的时候在application.properties配置即可 ############## ...
- Tomcat7/8访问Server Status、Manager App、Host Manager出现403 forbidden
在配置好Tomcat7/8后,我们往往需要访问Tomcat7/8的Manager以及Host Manager.就需要在tomcat-users.xml中配置用户角色来实现.在地址栏输入:localho ...
- CISCO ASA 5505 经典配置案例
nterface Vlan2 nameif outside ----------------------------------------对端口命名外端口 security-level 0 -- ...
- tomcat如何登录Server Status、Manager App、Host Manager
启动tomcat后,访问127.0.0.1会进入如下页面 版权声明:本文为博主原创文章,未经博主允许不得转载. 原文地址:https://www.cnblogs.com/poterliu/p/9602 ...
随机推荐
- 语音笔记:CTC
CTC全称,Connectionist temporal classification,可以理解为基于神经网络的时序类分类.语音识别中声学模型的训练属于监督学习,需要知道每一帧对应的label才能进行 ...
- 软件工程项目之摄影App(第二次冲刺)
第二次冲刺阶段做出了登录,还有首页.基本界面也成型了. 登录验证码是用了mob的验证码skd.
- PAT 1014 福尔摩斯的约会
https://pintia.cn/problem-sets/994805260223102976/problems/994805308755394560 大侦探福尔摩斯接到一张奇怪的字条:“我们约会 ...
- PAT 1003 我要通过!
https://pintia.cn/problem-sets/994805260223102976/problems/994805323154440192 “答案正确”是自动判题系统给出的最令人欢喜的 ...
- Oracle 控制文件管理
控制文件是一个很小的二进制文件(10MB左右),含有数据库结构信息,包括数据文件和日志文件信息.控制文件在数据库创建时被自动创建,并在数据库发生物理变数时更新.控制文件被不断更新,在任何时候都要保证控 ...
- NF5280M4 安装 Win2016 的方法
1. 前提条件, 硬盘大于2T, 2. 必须使用最新版本的 Win2016 首先 win2016的可用序列号 • Windows Server 数据中心 CB7KF-BWN84-R7R2Y-793K2 ...
- php的一些算法题
1.有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,请编程输出两年内每个月的兔子总数为多少? <?php function getRes ...
- SQL SELECT INTO
SQL SELECT INTO 语句 1. SELECT *INTO table1 FROM table //将table的数据复制到 table2中 但是我自己进行试验时, SELECT * INT ...
- Java和Android的Lru缓存,及其实现原理
一.概述 Android提供了LRUCache类,可以方便的使用它来实现LRU算法的缓存.Java提供了LinkedHashMap,可以用该类很方便的实现LRU算法,Java的LRULinkedHas ...
- PHP的安装,编译,扩展工具
1.基本容易混淆的概念 pecl php的社区贡献扩展库,全称为PHP Extension Community Library, 是php的底层库, 使用C语言编写 pear php的应用扩展库,全称 ...