安全配置和維護Apache WEB Server(4)_Windows教程
apache服務器采用默認配置。主目錄為/home/httpd/html,主機域名為Phoenix.XXXX.com,且別名到www.XXXX.com中,并且設置srm.conf加一行別名定義如下:
Alias/pub/home/ftp/pub/
更改默認應用程序類型定義如下:
DefaultType application/octet-stream
最后在/etc/httpd/conf/access.conf中增加一項定義
Options Indexes
AllowOverride AuthConfig
order allow,deny
allow from all
注:Options Indexes允許在找不到index.html文件的情況下允許列出目錄/文件列表。AllowOverride AuthConfig允許做基本的用戶名和口令驗證。這樣的話,需要在/home/ftp/pub目錄下放入.htaccess,內容如下:
[root@shopu pub]# more .htaccess
AuthName Branch Office Public Software Download Area
AuthType Basic
AuthUserFile /etc/.usrpasswd
require valid-user
用# htpasswd -c /etc/.usrpasswd user1 分別創建不同的允許訪問/pub下文件服務的外部用戶名和口令。
(2)在防火墻上配置反向代理技術.
在/etc/httpd/conf/httpd.conf中加入 NameVirtualHost xxx.xxx.xxx.xxx
# xxx.xxx.xxx.xxx ----->是防火墻外部在互聯網上永久IP地址
servername www.XXXX.com
errorlog /var/log/httpd/error_log
transferlog /var/log/httpd/access_log
rewriteengine on
proxyrequests off
usecanonicalname off
rewriterule ^/(.*)$ http://xxx.xxx.xx.x/$1 Apache服務器的IP地址。
servername http://download.XXXX.com/pub/
errorlog /var/log/httpd/download/error_log
transferlog /var/log/httpd/download/access_log
rewriteengine on
proxyrequests off
usecanonicalname off
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 所帶來的好處。
- 相關鏈接:
- 教程說明:
Windows教程-安全配置和維護Apache WEB Server(4)。