基於mod_ssl配置https服務器

 


 

實驗須知:node

         實驗主機1:192.168.1.11,做爲web服務器web

         實驗主機2:192.168.1.12,做爲CA簽署證書的主機apache

 

配置流程:vim

(1)      爲服務器申請數字證書;這裏出於測試的目的,須要創建私有CAwindows

  1. 建立私有CA瀏覽器

  2. web服務器上建立證書籤署請求bash

  3. CA證書籤署服務器

(2)      配置httpd支持使用ssl及使用的證書併發

(3)      測試基於https訪問的主機ide

 

配置步驟:

        

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)
相關文章
相關標籤/搜索