设为首页 收藏本站
查看: 910|回复: 0

[经验分享] 基于mod_ssl配置https服务器

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-8-19 09:05:01 | 显示全部楼层 |阅读模式
实验须知:
         实验主机1:192.168.1.11,作为web服务器
         实验主机2:192.168.1.12,作为CA签署证书的主机

配置流程:
(1)      为服务器申请数字证书;这里出于测试的目的,需要建立私有CA
  • 创建私有CA
  • 在web服务器上创建证书签署请求
  • CA证书签署

(2)      配置httpd支持使用ssl及使用的证书
(3)      测试基于https访问的主机

配置步骤:

在12主机:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[iyunv@node2 ~]# cd /etc/pki/CA
[iyunv@node2 CA]# (umask 077;openssl genrsa -out private/cakey.pem2048)Generating RSA private key, 2048 bit long modulus
..............................................................................+++
..................................................................+++
e is 65537 (0x10001)
[iyunv@node2 CA]# openssl req -new -x509 -key private/cakey.pem -outcacert.pem -days 10000
              CN
              BJ
              BJ
              Magedu
              Ops
              ca.mageu.com
[iyunv@node2 CA]# touch index.txt
[iyunv@node2 CA]# echo 01 > serial




在11主机:

1
2
3
4
5
6
7
8
9
10
11
12
13
#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主机:
1
2
3
  [iyunv@node2 tmp]# cd /tmp/
[iyunv@node2 tmp]# opensslca -in http.csr -out http.crt -days 3655
[iyunv@node2 tmp]#scp  http.crt172.16.100.11:/etc/httpd/ssl/




在11主机:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#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主机:   
1
2
#cd/etc/pki/CA
         #scpcacert.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:以持久连接的模式测试
使用示例:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#cd/vhosts/a.com/htdocs/
  #vim tc.txt
       www.a.com
  [iyunv@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)
[iyunv@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)
[iyunv@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)



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-100917-1-1.html 上篇帖子: apache https.conf详解 下篇帖子: http实现虚拟主机的配置 服务器
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表