分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

Apache网页安全优化

发布时间:2023-09-06 02:12责任编辑:郭大石关键词:暂无标签
参考手工编译安装Apache ?????安装这些包 yum install gcc gcc-c++ ?make ?pcre pcre-devel zlib-devel -y

./configure \
--prefix=/usr/local/httpd \
--enable-deflate \ ??//支持可压缩
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi

接下来 ??make &&make install
**修改它的配置文件 ??vi /etc/init.d/httpd 在文件最前面插入下面的行

#!/bin/sh

chkconfig:2345 85 15

# description:Apache is a World Wide Web server.


给它执行权限 ?chmod +x /etc/init.d/httpd

chkconfig --add httpd
chkconfig --list httpd
chkconfig --level 35 httpd on

建立软链接 ln -s /usr/local/httpd/conf/httpd.conf /etc/httpd.conf
vi /usr/local/apache/conf/httpd.conf 修改以下两行
Listen:IPV4
ServerName:主机名.域名

开启网站服务 service httpd start
vim /etc/httpd.conf
LoadModule headers_module modules/mod_headers.so
LoadModule deflate_module modules/mod_deflate.so ????//开启 去掉前面#
LoadModule filter_module modules/mod_filter.so
末尾添加:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript
DeflateCompressionLevel 9
SetOutputFilter DEFLATE
</IfModule>

cd /usr/local/httpd/bin
./apachectl -t
Syntax OK ????//验证配置文件成功

验证模块
./apachectl -t -D DUMP_MODULES | grep "deflate"
deflate_module (shared)

网页缓存 ????./configure \
--prefix=/usr/local/httpd \
--enable-deflate \
--enable-expires \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi

vim /etc/httpd.conf
LoadModule expires_module modules/mod_expires.so
末尾添加:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 50 seconds" ??//50s之后过期
</IfModule>

cd /usr/local/httpd/bin
./apachectl -t
Syntax OK

查看模块 ?./apachectl -t -D DUMP_MODULES | grep "expires"
expires_module (shared)

**安全优化 ????yum install zlib-devel -y

./configure \
--prefix=/usr/local/httpd \
--enable-deflate \
--enable-so \
--enable-rewrite \
--enable-charset-lite \
--enable-cgi
主配置文件修改

<Directory "/usr/local/httpd/htdocs">
Options Indexes FollowSymLinks

AllowOverride NoneRequire all granted下插入:RewriteEngine OnRewriteCond %{HTTP_REFERER} !^http://benet.com/.*$ [NC]RewriteCond %{HTTP_REFERER} !^http://benet.com$ [NC]RewriteCond %{HTTP_REFERER} !^http://www.benet.com/.*$ [NC]RewriteCond %{HTTP_REFERER} !^http://www.benet.com/$ [NC]RewriteRule .*\.(gif|jpg|swf)$ http://www.benet.com/error.png

</Directory>

LoadModule rewrite_module modules/mod_rewrite.so ??//开启

./apachectl -t -D DUMP_MODULES | grep "rewrite"
rewrite_module (shared)**

**隐藏版本信息 ?Include conf/extra/httpd-default.conf ??去#,开启

vim httpd-default.conf

ServerTokens Prod ???????????//只显示名称,没有版本
ServerSignature Off

**

Apache网页安全优化

原文地址:http://blog.51cto.com/13706698/2165569

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved