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 ...
随机推荐
- Linux实践一:问题及解决
安装ubuntu出现的问题 : 打开镜像.iso文件,v-box好像是不识别这种格式的,它识别的好像是.vdi等格式,所以要用vm虚拟机打开镜像安装 打开镜像,按照步骤安装后,安装很久后,出现问题.初 ...
- 第七周linux内核分析
可执行程序的装载 作者 黎静+ 原创作品转载请注明出处 + <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-100002900 ...
- javac编译提示错误需要为 class、interface 或 enum
HelloWorld.java:1: 需要为 class.interface 或 enum锘缝ublic class HelloWorld{^1 错误 这个错误出现的原因主要是在中文操作系统中,使用一 ...
- CMake系列之二:入门案例-单个源文件
编写一个源码文件 如下 #include<stdio.h> #include<stdlib.h> double power(double base,int exponent) ...
- Filter学习:项目第八阶段
public interface Filter A filter is an object that performs filtering tasks on either the request ...
- Linux 忘记root密码
1 将系统重启,读秒的时候按下任意键就会出现如下图菜单界面 2 进入上图菜单界面之后,按e键就可以进入grub的编辑模式 3 选择第二行 kernel开头,再按 e 键进入该行的编辑界面中,然后在出现 ...
- intval()和int()
int intval ( mixed $var [, int $base ] ) 通过使用特定的进制转换(默认是十进制),参数base表示进制,只有当var是字符串时,base才会有意义,表示按 ...
- jquery添加刪除
創建元素的方法:jquery.javascript/dom,html/text var txt1="<p>Text.</p>"; ...
- maven dependcymanage作用在父类里面定义依赖包 子类不会自动继承需要主动使用 这样解决了父类引用任意包 子类就会引用的问题
maven dependcymanage作用在父类里面定义依赖包 子类不会自动继承需要主动使用 这样解决了父类引用任意包 子类就会引用的问题 子类在引用时候 不需要加上版本号
- filebeat 配置文件参数
filebeat 配置 所有的 beats 组件在 output 方面的配置都是一致的,之前章节已经介绍过.这里只介绍 filebeat 在 input 段的配置,如下: filebeat: sp ...