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

[经验分享] apache服务之https、访问控制、status等功能

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-5-24 10:22:38 | 显示全部楼层 |阅读模式
https:
客户端:申请证书

1
2
3
[iyunv@martin ssl]# pwd
/etc/httpd/ssl
[iyunv@martin ssl]# (umask 077; openssl genrsa  -out martin01.key 2048)



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[iyunv@martin ssl]# openssl req -new -key martin01.key -out martin01.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 (2 letter code) [XX]:cn
State or Province Name (full name) []:zhejiang
Locality Name (eg, city) [Default City]:ningbo
Organization Name (eg, company) [Default Company Ltd]:martin
Organizational Unit Name (eg, section) []:martin
Common Name (eg, your name or your server's hostname) []:martin
Email Address []:martin@qq.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:



1
[iyunv@martin ssl]# scp -P 6789 martin01.csr marvin:/mydata/ssl/csr



CA服务器:审核证书

1
2
[iyunv@marvin CA]# openssl ca -in /mydata/ssl/csr/martin01.csr  -out /mydata/ssl/crt/martin01.crt -days 800
[iyunv@marvin CA]# scp -P6789 /mydata/ssl/crt/martin01.crt martin:/etc/httpd/ssl/



客户端:
1
2
3
4
5
6
7
8
9
# Required modules: mod_log_config, mod_setenvif, mod_ssl,
#          socache_shmcb_module (for default value of SSLSessionCache)

[iyunv@martin httpd]# vim /etc/httpd/httpd.conf
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule log_config_module modules/mod_log_config.so
Include /etc/httpd/extra/httpd-ssl.conf



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[iyunv@martin httpd]# vim extra/httpd-ssl.conf
DocumentRoot "/www/web/ssl"
ServerName www.ssl.com:443
<Directory "/www/web/ssl">
        Options  none
        AllowOverride all
        Require all granted
</Directory>
SSLCertificateFile /etc/httpd/ssl/martin01.crt
SSLCertificateKeyFile /etc/httpd/ssl/martin01.key



[iyunv@martin httpd]# echo ok > /www/web/ssl/index.html
[iyunv@martin httpd]# httpd -t
Syntax OK
[iyunv@martin httpd]# /etc/init.d/httpd restart



证书创建若有疑问

QQ截图20160524102043.jpg
QQ截图20160524102051.jpg
虚拟主机:
1
2
3
[iyunv@martin httpd]# vim /etc/httpd/httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
Include /etc/httpd/extra/httpd-vhosts.conf



1
2
3
4
5
6
7
8
9
10
[iyunv@martin httpd]# vim extra/httpd-vhosts.conf
<VirtualHost *:80>
    DocumentRoot  "/www/web/martin"
    ServerName www.martin.com
    <Directory "/www/web/martin">
        Options  none
        AllowOverride all
        Require all granted
    </Directory>
</VirtualHost>




1
[iyunv@martin httpd]# echo martin > /www/web/martin/index.html



QQ截图20160524102059.jpg

基于IP访问控制:2.4新特性

    允许所有主机访问:Require all granted
    拒绝所有主机访问:Require all deny
控制某主机的访问:

    Require ip IPADDR
    Require not ip IPADDR

    Require host IPADDR
   Require not host IPADDR
1
2
3
4
5
6
<Directory "/www/web/martin">
        Options  none
        AllowOverride all
        Require ip 192.168.1
        Require all denied
</Directory>





status:

1
2
3
[iyunv@martin htdocs]# vim  /etc/httpd/httpd.conf
LoadModule status_module modules/mod_status.so
Include /etc/httpd/extra/httpd-info.conf



1
2
3
4
5
6
7
[iyunv@martin htdocs]# vim /etc/httpd/extra/httpd-info.conf
<Location /server-status>
    SetHandler server-status
    #Require host .example.com
    Require ip 127
    Require ip 192.168.1
</Location>



QQ截图20160524102109.jpg

这是一个httpd的内嵌handler,通过status可查看当前服务器的状态。它通过一个HTML页面展示了当前服务器的统计数据。这些数据通常包括但不限于:
(1) 处于工作状态的worker进程数;
(2) 空闲状态的worker进程数;
(3) 每个worker的状态,包括此worker已经响应的请求数,及由此worker发送的内容的字节数;
(4) 当前服务器总共发送的字节数;
(5) 服务器自上次启动或重启以来至当前的时长;
(6) 平均每秒钟响应的请求数、平均每秒钟发送的字节数、平均每个请求所请求内容的字节数;
基于用户的访问控制
1
2
3
4
5
6
7
8
9
<Directory "/www/web/martin">
        Options  none
        AuthType Basic
        AuthName "Admin status"
        AuthUserFile /etc/httpd/conf/.htpasswd
        AllowOverride all
        Require ip 192.168.1
        Require all denied
    </Directory>



1
2
3
4
[iyunv@martin httpd]# /usr/local/apache/bin/htpasswd -m -c /etc/httpd/.htpasswd admin
New password:
Re-type new password:
Adding password for user admin



QQ截图20160524102117.jpg


运维网声明 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-220999-1-1.html 上篇帖子: Apache语言支持设置 下篇帖子: apache+多tomcat集群 status
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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