Active Directory シングルフォレスト、シングルドメインの構成
virtual.prosper2.org
ADサーバ#1(VMad01:192.168.10.204)
WindowsServer2008R2SP1(試用版)
ActiveDirectory?とDNSサービス稼動中
ADサーバ#2(VMad02:192.168.10.205)
WindowsServer2008R2SP1(試用版)
ActiveDirectory?とDNSサービス稼動中
#1の情報を自動レプリケーション
プロキシ(VMproxy01:192.168.10.201):CentOS6.3
squid(3.1.10)
samba(3.5.10)
yumでのインストール
[VMproxy01]# yum install squid samba samba-winbind
通常上位プロキシ(VMpxext01:192.168.10.202):CentOS6.3
squid(3.1.10)
yumでのインストール
[VMproxy01]# yum install squid
ブラウザ(192.168.20.0/24:DHCP):WindowsXP
InternetExplorer8
#vi /etc/resolv.conf search VIRTUAL.PROSPER2.LOCAL nameserver 192.168.10.204
#vi /etc/hosts 127.0.0.1 VMproxy01
#vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=VMproxy01
#vi /etc/samba/smb.conf workgroup = VIRTUAL server string = VMproxy01 security = ads hosts allow = 127. realm = VIRTUAL.PROSPER2.LOCAL
#LANG=en_US ;authconfigがうまく動かない場合があるらしい #authconfig --enablewinbind --update ;コマンドで/etc/nsswitch.confを書き換えてくれる #authconfig --krb5kdc=192.168.10.204 --krb5realm=VIRTUAL.PROSPER2.LOCAL --update ;コマンドで/etc/krb5.confを書き換えてくれる
ユーザ名:squid
パスワード:squidpass
として設定する。
一応ADのユーザになるわけだから、このユーザ名ではwindowsログオンできないようにしておいたほうがいいのかもしれない。
#/etc/init.d/smb stop #/etc/init.d/winbind stop ;テストでしくったときに影響を与えないようにサービスとしては停止しておく # net ads join -U squid ;ADに参加しているユーザを指定(ここではプロキシ動作のためのADユーザを指定) Enter squid's password: Using short domain name -- VIRTUAL Joined 'VMPROXY01' to realm 'virtual.prosper2.org' No DNS domain configured for vmproxy01. Unable to perform DNS Update. DNS update failed!
なんかエラーみたいだけどOK。ADで自動インストールされたDNSにも正引き、逆引きで登録しておく。
#/etc/init.d/smb start #/etc/init.d/winbind start #chkconfig --add smb #chkconfig --add winbind #chkconfig smb on #chkconfig winbind on
#wbinfo -t checking the trust secret for domain DOMAIN via RPC calls succeeded
と表示されていればOK(rootでのみ確認可能)
#wbinfo -u VIRTUAL\administrator VIRTUAL\guest VIRTUAL\krbtgt VIRTUAL\squid VIRTUAL\u-limit VIRTUAL\u-unlimit
でユーザがリストアップされていればOK
#wbinfo -a VIRTUAL.PROSPER2.ORG\\UID%PWD plaintext password authentication succeeded challenge/response password authentication succeeded
と表示されていればOK
# id squid uid=23(squid) gid=23(squid) groups=23(squid) # usermod -G wbpriv squid # id squid uid=23(squid) gid=23(squid) groups=23(squid),88(wbpriv)
でsquidがwbprivに所属していればOK
#基本的な設定
visible_hostname VMproxy01
#NTLM認証の基本的な設定とACL
auth_param ntlm program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp auth_param ntlm children 5 external_acl_type ldap_group %LOGIN /usr/lib/squid/squid_ldap_group -v 3 -b "OU=ALPHA,DC=VIRTUAL,DC=PROSPER2,DC=ORG" -h 192.168.10.204 -D "CN=squid,OU=ALPHA,DC=VIRTUAL,DC=PROSPER2,DC=ORG" -w squidpass -f "(&(objectclass=person)(sAMAccountName=%u)(memberOf=CN=%g,OU=ALPHA,DC=VIRTUAL,DC=PROSPER2,DC=ORG))" -S acl gr_unlimit external ldap_group proxy_unlimit acl gr_limit external ldap_group proxy_limit acl whitelist url_regex -i "/etc/squid/whitelist.txt" acl intrasite url_regex -i "/etc/squid/intrasite.txt" acl clientlist src "/etc/squid/clientlist.txt"
#ADに登録されたメンバーにプロキシ利用の許可を与える
# deny : from unexpected clients http_access deny !clientlist # permit : any client to whitelist # no logging username http_access allow whitelist # permit : AD Security Group # logging username http_access allow gr_unlimit http_access allow gr_limit # deny : default http_access deny all # 192.168.10.202 VMpxext01 cache_peer 192.168.10.202 parent 3128 0 no-query # permit : any client to whitelist cache_peer_access 192.168.10.202 allow whitelist # permit : Unlimit group to any cache_peer_access 192.168.10.202 allow gr_unlimit # permit : Limit group to intrasite cache_peer_access 192.168.10.202 allow gr_limit intrasite cache_peer_access 192.168.10.202 deny gr_limit !intrasite cache_peer_access 192.168.10.202 deny all always_direct allow intrasite never_direct allow all
#tailf /var/log/squid/access.log 1357570423.423 0 192.168.20.35 TCP_DENIED/407 4670 GET http://www.google.co.jp/ - NONE/- text/html 1357570423.815 373 192.168.20.35 TCP_MISS/200 25077 GET http://www.google.co.jp/ VIRTUAL\XXXX DIRECT/74.125.235.120 text/html
リターンコード407で認証が必要とされたあとにすぐ200で正常に完了している。
whitelist.txt,intrasite.txt,clientlist.txt は squid の通常ACLを利用しているため
テキストファイルを反映しても、設定ファイルの再読み込み(reload)をしないと
反映されない。
ユーザ名は squid.conf のhttp_access ラインで判断するため http_accessのACLにユーザ判別の
処理が含まれていないと表示することができない。
そのため、whitelistのアクセス時にはユーザ名がロギングされない。
システムユーザおよび制限ユーザがアクセスできるホワイトリストはアクセスしたいURLだけでなく
同時に読み込まれるURLについても許可してあげないと、挙動がおかしくなる可能性があるので、注意
(下記コンフィグにあるように、microsoftのサイトだが、別ドメインのファイルを読んでいる)
制限ユーザであれば、アクセスできないだけだが、システムユーザだと407で弾かれるため、
ブラウザでのポップアップやバックグラウンドで動作するプログラムでは正常に動作しない可能性がある。
[root@VMproxy01 ~]# cat /etc/squid/squid.conf auth_param ntlm program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp auth_param ntlm children 5 external_acl_type ldap_group %LOGIN /usr/lib/squid/squid_ldap_group -v 3 -b "OU=ALPHA,DC=VIRTUAL,DC=PROSPER2,DC=ORG" -h 192.168.10.204 -D "CN=squid,OU=ALPHA,DC=VIRTUAL,DC=PROSPER2,DC=ORG" -w squidpass -f "(&(objectclass=person)(sAMAccountName=%u)(memberOf=CN=%g,OU=ALPHA,DC=VIRTUAL,DC=PROSPER2,DC=ORG))" -S acl gr_unlimit external ldap_group proxy_unlimit acl gr_limit external ldap_group proxy_limit acl whitelist url_regex -i "/etc/squid/whitelist.txt" acl intrasite url_regex -i "/etc/squid/intrasite.txt" acl clientlist src "/etc/squid/clientlist.txt" acl manager proto cache_object acl localhost src localhost acl localhost src 127.0.0.1/32 acl SSL_ports port 443 acl Safe_ports port 80 # http acl Safe_ports port 21 # ftp acl Safe_ports port 443 # https acl Safe_ports port 70 # gopher acl Safe_ports port 210 # wais acl Safe_ports port 1025-65535 # unregistered ports acl Safe_ports port 280 # http-mgmt acl Safe_ports port 488 # gss-http acl Safe_ports port 591 # filemaker acl Safe_ports port 777 # multiling http acl CONNECT method CONNECT http_access allow manager localhost http_access deny manager http_access deny !Safe_ports http_access deny CONNECT !SSL_ports # deny : from unexpected clients http_access deny !clientlist # permit : any client to whitelist # no logging username http_access allow whitelist # permit : AD Security Group # logging username http_access allow gr_unlimit http_access allow gr_limit # deny : default http_access deny all # 192.168.10.202 VMpxext01 cache_peer 192.168.10.202 parent 3128 0 no-query # permit : any client to whitelist cache_peer_access 192.168.10.202 allow whitelist # permit : Unlimit group to any cache_peer_access 192.168.10.202 allow gr_unlimit # permit : Limit group to intrasite cache_peer_access 192.168.10.202 allow gr_limit intrasite cache_peer_access 192.168.10.202 deny gr_limit !intrasite cache_peer_access 192.168.10.202 deny all always_direct allow intrasite never_direct allow all # Squid normally listens to port 3128 http_port 3128 # We recommend you to use at least the following line. hierarchy_stoplist cgi-bin ? # Uncomment and adjust the following to add a disk cache directory. #cache_dir ufs /var/spool/squid 100 16 256 # Leave coredumps in the first cache dir coredump_dir /var/spool/squid # Add any of your own refresh_pattern entries above these. refresh_pattern ^ftp: 1440 20% 10080 refresh_pattern ^gopher: 1440 0% 1440 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 refresh_pattern . 0 20% 4320 visible_hostname VMproxy01
[root@VMproxy01 ~]# cat /etc/squid/whitelist.txt
adobe.com adobe.co.jp adobe.jp windowsupdate.com windowsupdate.co.jp microsoft.com microsoft.co.jp aspnetcdn.com webtrends.com jquery.com msn.com atdmt.com
[root@VMproxy01 squid]# cat /etc/squid/intrasite.txt www.prosper2.org taruo.net ugtop.com
[root@VMproxy01 squid]# cat /etc/squid/clientlist.txt 192.168.10.0/24 192.168.20.0/24