实验须知:

         实验主机1:192.168.1.11,作为web服务器

         实验主机2:192.168.1.12,作为CA签署证书的主机

 

配置流程:

(1)      为服务器申请数字证书;这里出于测试的目的,需要建立私有CA

  1. 创建私有CA

  2. web服务器上创建证书签署请求

  3. CA证书签署

(2)      配置httpd支持使用ssl及使用的证书

(3)      测试基于https访问的主机

 

配置步骤:

        

12主机:

[root@node2 ~]# cd /etc/pki/CA
[root@node2 CA]# (umask 077;openssl genrsa -out private/cakey.pem2048)Generating RSA private key, 2048 bit long modulus
..............................................................................+++
..................................................................+++
e is 65537 (0x10001)
[root@node2 CA]# openssl req -new -x509 -key private/cakey.pem -outcacert.pem -days 10000
              CN
              BJ
              BJ
              Magedu
              Ops
              ca.mageu.com
[root@node2 CA]# touch index.txt
[root@node2 CA]# echo 01 > serial

 

11主机:

  

#cd/etc/httpd/
#mkdir ssl
#cd ssl
# (umask077;openssl genrsa -out http.key 1024)
#openssl req-new -key http.key -out http.csr
         CN
         BJ
         BJ
         MageEdu
Ops
www.a.com
 
#scp http.csr@172.16.11.12:/tmp

 

12主机:

[root@node2 tmp]# cd /tmp/
[root@node2 tmp]# opensslca -in http.csr -out http.crt -days 3655
[root@node2 tmp]#scp  http.crt172.16.100.11:/etc/httpd/ssl/

 

11主机:

#yum install mod_ssl-y
#rpm -ql mod_ssl
#vim /etc/httpd/conf.d/ssl.conf
         ………..
<VirtualHost192.168.1.11:443>
       DocumentRoot "/vhosts/a.com/htdocs"
       ServerName www.a.com:443
         ………
         SSLCertificateFile/etc/httpd/ssl/http.crt
         SSLCertificateKeyFile/etc/httpd/ssl/http.key
         ………..
         #httpd–t
         #servicehttpd restart
         #ss–tnl
                   …..查看是否有443端口……..

 

12主机:   

#cd  /etc/pki/CA
#scp cacert.pem 172.16.1.11:/tmp

此时可以在浏览器中输入:https://192.168.1.11测试;

 

最后一步,将/tmp目录下的证书cacert.pem文件导入windows桌面,并更改名为cacert.crt,双击安装证书即可;现在我们需要在浏览器中输入:https://www.a.com能正常显示网页信息,就在windows里面改hosts文件:

 ……..添加…………..

 192.168.1.11 www.a.com

再次输入https://ww.a.com,观察显示结果

        

 


 

压力测试工具ab的使用:

         用法:

                #ab [options] URL

                  -c:请求的最大并发数

                 -n:总的请求数

                  -k:以持久连接的模式测试

使用示例:

#cd  /vhosts/a.com/htdocs/
#vim tc.txt
   www.a.com
[root@node1htdocs]# ab -n 100 -c 10 http://www.a.com/rc.txt
This is ApacheBench, Version 2.3<$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus TechnologyLtd, http://www.zeustech.net/
Licensed to The Apache Software Foundation,http://www.apache.org/
 
Benchmarking www.a.com (bepatient).....done
 
 
Server Software:        Apache/2.2.15
Server Hostname:        www.a.com
Server Port:            80
 
Document Path:          /rc.txt
Document Length:        279 bytes
 
Concurrency Level:      10
Time taken for tests:   0.042 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Non-2xx responses:      102
Total transferred:      46818 bytes
HTML transferred:       28458 bytes
Requests per second:    2406.68 [#/sec] (mean)
Time per request:       4.155 [ms] (mean)
Time per request:       0.416 [ms] (mean, across all concurrentrequests)
Transfer rate:          1100.35 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   0   0.2      0      1
Processing:     0   3   6.0      1     20
Waiting:        0   2   5.3      1     20
Total:          1   4   6.0      1     20
 
Percentage of the requests served within acertain time (ms)
 50%      1
 66%      1
 75%      2
 80%      3
 90%     14
 95%     20
 98%     20
 99%     20
 100%    20 (longest request)
[root@node1 htdocs]# ab -n 1000 -c 100http://www.a.com/rc.txt
This is ApacheBench, Version 2.3<$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus TechnologyLtd, http://www.zeustech.net/
Licensed to The Apache Software Foundation,http://www.apache.org/
 
Benchmarking www.a.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
 
 
Server Software:        Apache/2.2.15
Server Hostname:        www.a.com
Server Port:            80
 
Document Path:          /rc.txt
Document Length:        279 bytes
 
Concurrency Level:      100
Time taken for tests:   0.228 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Non-2xx responses:      1005
Total transferred:      461295 bytes
HTML transferred:       280395 bytes
Requests per second:    4386.10 [#/sec] (mean)
Time per request:       22.799 [ms] (mean)
Time per request:       0.228 [ms] (mean, across all concurrentrequests)
Transfer rate:          1975.87 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   1   1.3      1      8
Processing:     8  20   9.9     18     52
Waiting:        8  20  10.0     18     51
Total:         10  22  10.2     20     54
 
Percentage of the requests served within acertain time (ms)
 50%     20
 66%     21
 75%     22
 80%     22
 90%     46
 95%     51
 98%     53
 99%     53
 100%    54 (longest request)
[root@node1 htdocs]# ab -n 10000 -c 100http://www.a.com/rc.txt
This is ApacheBench, Version 2.3<$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus TechnologyLtd, http://www.zeustech.net/
Licensed to The Apache Software Foundation,http://www.apache.org/
 
Benchmarking www.a.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
 
 
Server Software:        Apache/2.2.15
Server Hostname:        www.a.com
Server Port:            80
 
Document Path:          /rc.txt
Document Length:        279 bytes
 
Concurrency Level:      100
Time taken for tests:   1.303 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Non-2xx responses:      10016
Total transferred:      4597344 bytes
HTML transferred:       2794464 bytes
Requests per second:    7672.46 [#/sec] (mean)
Time per request:       13.034 [ms] (mean)
Time per request:       0.130 [ms] (mean, across all concurrentrequests)
Transfer rate:          3444.62 [Kbytes/sec] received
 
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   2   0.7      2      7
Processing:     6  11   2.3     11     24
Waiting:        6  11   2.3     10     24
Total:          9  13   2.4     12     26
 
Percentage of the requests served within acertain time (ms)
 50%     12
 66%     13
 75%     13
 80%     14
 90%     16
 95%     18
 98%     20
 99%     22
 100%    26 (longest request)