您當前所在位置:
首頁 →
服務器 →
WEB服務器 →
Apache用戶認證方法匯總
Apache用戶認證方法匯總
時間:2015-06-28 00:00:00
來源:IT貓撲網
作者:網管聯(lián)盟
我要評論(0)
- 一.基本的Apache用戶認證方法:
若對某一目錄下的文件如/home/ftp/pub需要做到用戶認證,則在httpd.conf
中加入下面的行
options indexes followsymlinks
allowoverride authconfig
order allow,deny
allow from all
用在目錄/home/ftp/pub下放文件.htaccess,內容如下:
authname "shared files"
authtype basic
authuserfile /etc/.passwd
require valid-user
用隨Apache來的程序htpasswd 生成文件/etc/.passwd,每行一個用戶名:密碼
只要能提供正確的用戶名和密碼對,就允許登錄訪問,這是針對任何地址來的
請求都要求提供用戶名和密碼認證。
二.針對部分網段或地址要求認證。
若公司LAN所在網段為192.168.0.0/24,且有一防火墻專線接入Internet,
內部網卡的地址為192.168.0.1/32,則現(xiàn)在希望所有通過撥本地163通過
防火墻上的apache反向代理向LAN上的另一WWW服務器訪問時需要認證,而本地
LAN上的用戶不需認證??梢栽趆ttpd.conf中放入:
〈Directory /home/ftp/pub>
Options Indexes FollowSymLinks
AllowOverride AuthConfig
order deny,allow
deny from 192.168.0.1
〈/Directory>
且在/home/ftp/pub/.htaccess中放入:
AuthName "shared files"
AuthType Basic
AuthUserFile /etc/.passwd
require valid-user
satisfy any
三.對同一目錄及其下的子目錄有不同的權限,僅某些人可以存取一目錄下的子目錄。
如有一目錄/home/ftp/pub/sales,有三個用戶user1,user2,user3都需要用戶名
和密碼進入/home/ftp/pub,但僅user1,user2能進入/home/ftp/pub/sales.則
放下面的行到httpd.conf
Options Indexes
AllowOverride AuthConfig
order allow,deny
allow from all
Options Indexes
AllowOverride AuthConfig
order allow,deny
allow from all
且看/home/ftp/pub/.htaccess為:
AuthName "shared files"
AuthType Basic
AuthUserFile /etc/.passwd
require valid-user
且看/home/ftp/pub/sales/.htaccess
AuthName "shared files"
AuthType Basic
AuthUserFile /etc/.passwd
AuthGroupFile /etc/.salesgroup
require group manager
且文件/etc/.passwd內容為:
user1:passwd1
user2:passwd2
user3:passwd3
且文件/etc/.salesgroup內容為:
manager: user1 user2關鍵詞標簽:匯總,方法,認證,用戶,
相關閱讀
熱門文章
ISAPI Rewrite實現(xiàn)IIS圖片防盜鏈
IIS6.0下配置MySQL+PHP5+Zend+phpMyAdmin
在Windows服務器上快速架設視頻編解碼器全攻略
win2000server IIS和tomcat5多站點配置
人氣排行
XAMPP配置出現(xiàn)403錯誤“Access forbidden!”的解決辦法
WIN2003 IIS6.0+PHP+ASP+MYSQL優(yōu)化配置
訪問網站403錯誤 Forbidden解決方法
如何從最大用戶并發(fā)數(shù)推算出系統(tǒng)最大用戶數(shù)
Server Application Unavailable的解決辦法
報錯“HTTP/1.1 400 Bad Request”的處理方法
Windows Server 2003的Web接口
http 500內部服務器錯誤的解決辦法(windows xp + IIS5.0)