apache 配置用户认证 域名跳转 日志 静态缓存文件 防盗链接

配置文件:/usr/local/apache2/conf/extra/httpd-vhosts.conf

<VirtualHost *:80>

ServerAdmin [email protected]

DocumentRoot "/data/www"

ServerName www.1.com

ServerAlias www.a.com www.b.com

#配置用户认证

<Directory /data/www>

AllowOverride AuthConfig

AuthName "132"

AuthType Basic

AuthUserFile /data/.htpasswd

require valid-user

</Directory>

#配置域名跳转

<IfModule mod_rewrite.c>

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www.a.com$ [OR]

RewriteCond %{HTTP_HOST} ^www.b.com$

RewriteRule ^/(.*)$ http://www.1.com/$1 [R=301,L]

</IfModule>

#配置日志

ErrorLog "/usr/local/apache2/logs/error.log"

SetEnvIf Request_URI ".*\.gif$" image-request

SetEnvIf Request_URI ".*\.jpg$" image-request

SetEnvIf Request_URI ".*\.png$" image-request

SetEnvIf Request_URI ".*\.bmp$" image-request

SetEnvIf Request_URI ".*\.swf$" image-request

SetEnvIf Request_URI ".*\.js$" image-request

SetEnvIf Request_URI ".*\.css$" image-request

CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/1.com-access_%Y%m%d.log 86400" combined env=!image-request

#配置静态文件缓存

<IfModule mod_expires.c>

ExpiresActive on

ExpiresByType image/gif  "access plus 1 days"

ExpiresByType image/jpeg "access plus 24 hours"

ExpiresByType image/png "access plus 24 hours"

ExpiresByType text/css "now plus 2 hour"

ExpiresByType application/x-javascript "now plus 2 hours"

ExpiresByType application/javascript "now plus 2 hours"

ExpiresByType application/x-shockwave-flash "now plus 2 hours"

ExpiresDefault "now plus 0 min"

</IfModule>

#配置防盗链接

SetEnvIfNoCase Referer "^http://www.1.com" local_ref

SetEnvIfNoCase Referer "www.a.com" local_ref

SetEnvIfNoCase Referer "www.b.com" local_ref

SetEnvIfNoCase Referer "^$" local_ref

<filesmatch "\.(txt|doc|mp3|zip|rar|jpg|gif)">

Order Allow,Deny

Allow from env=local_ref

</filesmatch>

</VirtualHost>

时间: 2024-08-08 01:27:34

apache 配置用户认证 域名跳转 日志 静态缓存文件 防盗链接的相关文章

Apache配置用户认证、域名跳转、日志轮询、静态文件缓存、防盗链

使用版本为httpd-2.2.29 源码编译安装环境. 1.配置网站用户认证 编辑虚拟机主机配置文件 /usr/local/apache2/conf/extra/httpd-vhosts.conf,在虚拟主机配置文件段内加入绿色标示代码: <VirtualHost *:80> DocumentRoot "/data/www" ServerName www.123.com ServerAlias www.a.com www.b.com     <Directory *&

5.Apache用户认证,域名跳转,访问日志

[toc] Apache用户认证 11.18 Apache用户认证 用户认证功能就是在用户访问网站的时候,需要输入用户名密码才能进行访问.一些比较好总要的站点和网站后台都会加上用户认证,以保证安全. 1.下面对xavi.com站点来做一个全站的用户认证: vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf //把xavi.com那个虚拟主机编辑成如下内容 <VirtualHost *:80> DocumentRoot "/dat

Apache 配置用户认证

有些网页,要求使用账号和密码才能访问,如网站后台.phpMyAdmin .Wiki 平台等,需要注意的是,Apache 认证只限于安全性要求较低的地方,因为账户密码以明文传输 [[email protected] ~]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf <VirtualHost *:80> DocumentRoot "/data/www" ServerName www.test.com <Dire

Apache的用户认证、域名跳转、Apache的访问日志

Apache的用户认证 vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf //把111.com那个虚拟主机编辑成如下内容 <VirtualHost *:80>DocumentRoot "/data/wwwroot/111.com"ServerName 111.comServerAlias www.example.com<Directory /data/wwwroot/111.com>AllowOverri

How to put username &amp;password in MongoDB(Security&amp;Authentication)?(配置用户认证在MongoDB)

Default do not need username and password authenticate when access mongoDB ,I want to set up the user name & password for my mongoDB. so that any remote access will ask for the user name & password. one way is following: Shutdown Server and exitRe

nginx 配置用户认证

nginx 配置用户认证有两种方式: 1.auth_basic 本机认证,由ngx_http_auth_basic_module模块实现. 2.auth_request,由ngx_http_auth_request_module模块实现. 第一种方式:yum -y install httpd-tools //安装 htpasswd 工具htpasswd -c /etc/nginx/.passwd-www www //生成用户登录的认证文件chmod 600 /etc/nginx/.passwd-

Apache(httpd)配置--用户认证,域名跳转和访问日志配置

一.用户认证 用户认证功能就是在用户访问网站的时候,需要输入用户名密码才能进行访问.一些比较好总要的站点和网站后台都会加上用户认证,以保证安全.实例:下面对zlinux.com站点来做一个全站的用户认证: 步骤1:编辑虚拟主机配置文件 [[email protected] ~]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf //在linuxtest.com虚拟主机下编辑添加以下内容 <VirtualHost *:80> Documen

11.18-11.21 Apache的用户认证,域名跳转,Apache访问日志

 11.18Apache的用户认证 把相应参数copy进去第二个虚拟主机(为了不影响默认主机使用,所以选择了第二个虚拟主机) <Directory /data/wwwroot/www.123.com> //指定认证的目录 AllowOverride AuthConfig //这个相当于打开认证的开关 AuthName "123.com user auth" //自定义认证的名字,作用不大 AuthType Basic //认证的类型,一般为Basic,其他类型阿铭没用过 A

4.13 apache用户认证,跳转和访问日志

Apache用户认证 有的网站在访问的时候需要我们输入账户名和密码,这样做的好处是增加了安全性,但是用户体验会很差.但是在我们在工作中还需要在一些重要的地方做一些安全认证. 首先我们编辑虚拟主机的配置文件 vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf我们用第二个虚拟主机做实验,然后在 ServerName下面下上如下的内容<Directory /data/wwwroot/123.com> //指定认证的目录(这里的网址要和前面配置文