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 ...
随机推荐
- MySQL中wait_timeout的坑
今天遇到了一个问题,一个项目,放到服务器(tomcat)下面的跑,但第二天,总是报错,项目还不能跑 com.mysql.jdbc.exceptions.jdbc4.CommunicationsExce ...
- scipy的一些函数名
rvs:随机变量pdf:概率密度函数cdf:累计分布函数sf:残存函数(1-CDF)ppf:分位点函数(CDF的逆)isf:逆残存函数(sf的逆)stats:返回均值,方差,(费舍尔)偏态,(费舍尔) ...
- nodefs模块的使用demo
为什么要使用递归?因为stat本身就是一个异步的函数所有存在异步问题不能够进行循环遍历. 在使用该种方法时候需要注意的一点是必须要在箭头标记处进行数据数组的存取.否则会由于异步问题导致输出空或者其他问 ...
- [转帖] 读懂YML文件.. 书买了还没看完...
Copy From https://www.cnblogs.com/CloudMan6/p/8370501.html 读懂 Deployment YAML - 每天5分钟玩转 Docker 容器技 ...
- java中父进程与子进程
http://blog.csdn.NET/seelye/article/details/8269705
- Guava的RateLimiter在单机限流中的正确用法
错误使用 在实现限流时,网上的各种文章基本都会提到Guava的RateLimiter,用于实现单机的限流,并给出类似的代码: public void method() { RateLimiter ra ...
- python之tkinter使用-二级菜单
# 菜单功能说明:二级菜单 import tkinter as tk from tkinter import messagebox root = tk.Tk() root.title('菜单选择') ...
- java 里面的 native 方法
第一篇: 今天花了两个小时把一份关于什么是Native Method的英文文章好好了读了一遍,以下是我依据原文的理解. 一. 什么是Native Method 简单地讲,一个Native Meth ...
- 如何在Vue项目中引入jQuery?
假设你的项目由vue-cli初始化 (e.g. vue init webpack my-project). 在你的vue项目目录下执行: npm install jquery --save-dev 打 ...
- codeforces622B
The Time CodeForces - 622B 给你当前的时间(24小时制):HH:MM.输出 x 分钟后的时间是多少?(24小时制) 不明白可以看看例子哦- Input 第一行给出了当前时间, ...