第八卷 安全配置和維護Apache WEB Server(3 / 3)

Alias/pub/home/ftp/pub/

更改默認應用程序類型定義如下:

DefaultTypeapplication/octet-stream

最後在/etc/httpd/conf/access.conf中增加一項定義

OptionsIndexes

AllowOverrideAuthConfig

orderallow,deny

allowfromall

注:OptionsIndexes允許在找不到index.html文件的情況下允許列出目錄/文件列表。AllowOverrideAuthConfig允許做基本的用戶名和口令驗證。這樣的話,需要在/home/ftp/pub目錄下放入.htaccess,內容如下:

[root@shopupub]#more.htaccess

AuthNameBranchOfficePublicSoftwareDownloadArea

AuthTypeBasic

AuthUserFile/etc/.usrpasswd

requirevalid-user

用# htpasswd-c/etc/.usrpasswduser1分別創建不同的允許訪問/pub下文件服務的外部用戶名和口令。

(2)在防火牆上配置反向代理技術.

在/etc/httpd/conf/httpd.conf中加入 NameVirtualHostxxx.xxx.xxx.xxx

#xxx.xxx.xxx.xxx ----->是防火牆外部在互聯網上永久IP地址

servernamewww.XXXX.com

errorlog/var/log/httpd/error_log

transferlog/var/log/httpd/access_log

rewriteengineon

proxyrequestsoff

usecanonicalnameoff

rewriterule^/(.*)$http://xxx.xxx.xx.x/$1Apache服務器的IP地址。

servernamehttp://download.XXXX.com/pub/

errorlog/var/log/httpd/download/error_log

transferlog/var/log/httpd/download/access_log

rewriteengineon

proxyrequestsoff

usecanonicalnameoff

rewriterule^/(.*)$http://xxx.xxx.xx.x/$1同上Apache服務器的IP地址。

設置防火牆上的DNS,讓download.XXXX.com和www.XXXX.com都指向防火牆的外部網地址xxx.xxx.xxx.xxx。用http://www.XXXX.com訪問主頁,用http://download.XXXX.com/pub/訪問公共文件的下載區。

注:還需要在apache服務器主機上建立目錄/var/log/httpd/download/,否則會出錯。另外,也可以設置防火牆主機上的/home/httpd/html/index.html的屬性為750來阻止訪問,這是防外部用戶能訪問到防火牆上的Apache服務器的http://www.XXXX.com中。

總結:Apache Server是一個非常優秀,非常棒的服務器,隻要你正確配置和維護好Apache服務器,你就會感受到Apache Server 所帶來的好處。