Linux

Apache 웹 인증

CHOMAN 2015. 5. 26. 16:09

웹인증할 계정 생성

계정으로 인증

/usr/local/apache/bin/htpasswd [passwordfile] [username] [password]
-c : 처음 [passwordfile] 생성시 붙여줌

/usr/local/apache/bin/htpasswd -c /mrtg/hub/user/.htpasswd user1 : 유저1 
/usr/local/apache/bin/htpasswd /mrtg/hub/user/.htpasswd user2 : 유저2 (추가할때)


vim .htaccess 
- 인증걸 디렉토리에 만들어준다

<Files hades.html> : 파일별로 묶어줄때 쓰는 옵션
AuthName " MRTG1입니다"
AuthType Basic
AuthUserFile /mrtg/hub/user/.htpasswd
AuthGroupFile /dev/null
ErrorDocument 401 " i(=^.^=)i "
#satisfy any
#order deny,allow
#deny from all
#allow from XXX.XX.62.226
require valid-user
</Files> : 파일별로 묶어줄때 쓰는 옵션

<Files golden.html>: 파일별로 묶어줄때 쓰는 옵션
AuthName "MRTG2 입니다"
AuthType Basic
AuthUserFile /mrtg/hub/user/.htpasswd2
AuthGroupFile /dev/null
ErrorDocument 401 " i(=^.^=)i "
#satisfy any
#order deny,allow
#deny from all
#allow from XXX.XX.62.226
require valid-user
</Files> : 파일별로 묶어줄때 쓰는 옵션

/usr/local/apache/conf/extra/http-vhost.conf

<VirtualHost *:80>
# ServerAdmin takakocap@kensei.co.kr
DocumentRoot "/mrtg/hub/user/hades"
ServerName hs.xxxxdos.kr
<IfModule dir_module>
DirectoryIndex hades.html
</IfModule>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "/mrtg/hub/user/goldenet"
ServerName gold.xxxxdos.kr
<IfModule dir_module>
DirectoryIndex goldenet.html
</IfModule>
# ErrorLog "logs/mrtg.antiddos.kr-error_log"
# SetEnvIf Request_URI "\.png$" dontlog
# CustomLog "logs/mrtg.antiddos.kr-access_log" combined env=!dontlog
# Options ExecCGI FollowSymLinks
# AllowOverride All
</VirtualHost>


IP 별로 아파치 웹 인증

AuthName "Manager Page"
AuthType Basic
Order deny,allow
Deny from all
Allow from 125.137.xxx.xxx 211.176.xxx.xxx