Chinaunix首页 | 论坛 | 博客
  • 博客访问: 547588
  • 博文数量: 201
  • 博客积分: 7734
  • 博客等级: 少将
  • 技术积分: 1994
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-09 19:18
文章分类

全部博文(201)

文章存档

2011年(28)

2010年(173)

分类: LINUX

2010-06-13 18:09:10

1.进程控制
2.动态模块加载
3.虚拟主机

命令行下测试浏览http

links



个人名称空间的开启
1.在httpd.conf开启userdir public_html
2.在用户home目录中建立public_html目录,并创建index.html,并给予755权限。
3.修改/home/user1/public_html目录的context
4.建立链接
cd /var/....
ln -s /home/user1/public_html user1 



虚拟主机

1.基于域名的虚拟主机
2.基于IP的虚拟主机
3.基于商品的虚拟主机


以下为常用的基于域名的虚拟主机配置方法:


vim /etc/httpd/conf/httpd.conf

移动到最后,复制模版。



基础配置
----------------------
NameVirtualHost 192.168.0.36:80
       
DocumentRoot /var/www/virt1
ServerName station36.example.com



DocumentRoot /var/www/virt2
ServerName www36.example.com


*********************************************
别名
NameVirtualHost 192.168.0.36:80
       
DocumentRoot /var/www/virt1
ServerName station36.example.com
  ServerAlias web36.example.com 别名,使两个域名对应同一个主机。



----------------------

安全

NameVirtualHost 192.168.0.36:80

DocumentRoot /var/www/virt1
ServerName station36.example.com

options -Indexes  防止在子目录没有index.html文件时,直接列出目录内所有文件的现象


&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

NameVirtualHost 192.168.0.36:80

DocumentRoot /var/www/virt1
ServerName station36.example.com

options -Indexes -FollowSymLinks  防止以链接的方式访问到根目录。


*********************************************


ACL访问控制


NameVirtualHost 192.168.0.36:80
       
DocumentRoot /var/www/virt1
ServerName station36.example.com
  
order allow,deny
allow from 192.168.0.0/255.255.255.0
deny from 192.168.0.9



       
DocumentRoot /var/www/virt2
ServerName www36.example.com
   可指定具体控制的目录。
order deny,allow
deny from 192.168.0.0/255.255.255.0
allow from 192.168.0.9



*********************************************

1.生成认证的database

htpasswd -cm /etc/httpd/.htpasswd bob   
   -c:创建数据库   -m:MD5加密
htpasswd -m /etc/httpd/.htpasswd alice (注意此处不再创建,故只用-m,否则将覆盖已存在的数据库)

2.在需认证的站点根目录下生成.htaccess文件

AuthName "test"
AuthType basic
AuthUserFile /etc/httpd/.htpasswd
require user bob

3.在httpd.conf 中启用认证
 AllowOverride AuthConfig





DocumentRoot /var/www/virt1
ServerName station36.example.com

order allow,deny
allow from 192.168.0.36/255.255.255.0
deny from 192.168.0.36
AllowOverride AuthConfig



*********************************************

CGI
1.可减短访问路径
2.通过网页执行目录下的脚本


DocumentRoot /var/www/virt2
ServerName www36.example.com
Alias /pub "/var/www/virt2/pub/test/test1/test2/mail" 别名。可使路径变短。
ScriptAlias /pub/ "/var/www/virt2/pub" 可在网页中执行脚本。

order allow,deny
allow from 192.168.0.36/255.255.255.0
deny from 192.168.0.36
AllowOverride Authconfig




squid



http_port 3128   可修改
*

cache_mem 8 MB   建议设置为物理内存的1/3。
*

cache_dir ufs /var/spool/squid 100 16 256
*

acl all src 0.0.0.0/0.0.0.0
*

acl localhost src 127.0.0.1/255.255.255.255
*

http_access allow localhost
*

http_access deny all


acl all src 0.0.0.0/0

/var/log/squid  日志存放目录。


进行上网行为管理

#vim /etc/squid/squid.conf

-------------------
acl homepage url_regex -i mail news

http_access deny homepage    禁止url中含有mail、news关键字的访问
***************************************************
acl download urlpath_regex -i \.mp3$ \.rm$ \.tar$
http_access deny download    禁止url中以后缀名是mp3、rm、tar的文件下载。
-------------------


架设SQUID服务器要求如下:
1、设置HTTP端口为8080 Http_port 8080
2、允许example.com域在星期一至星期五的上午9:00-17:00可以通过squid代理访问INTENET,拒绝cracker.org

该代理服务器禁止所有通过该服务器下载mp3和avi格式的文件。禁止访问关键字中含有"mail"、"news"的链接。

1.http_port 8080

2.
acl example srcdomain .example.com
acl cracker srcdomain .cracker.com
acl work time MTWHF 9:00-17:00

http_access allow example work
http_access deny example
http_access deny cracker
3.
acl network url_regex -i mail news
acl download urlpath_regex -i \.mp3$ \.avi$
阅读(421) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~