
我該如何設定 Joomla 來要求或繞過基於訪客 IP 位址的身份驗證?
我想設定一個 Joomla 網站,要求訪客登錄,除非他們從特定的 IP 位址或子網路造訪。
另外,我希望登入是基於 LDAP 的。
我將在本地網路上託管 Joomla 站點,並透過具有連接埠轉發的路由器將其公開。
答案1
我想設定一個 Joomla 網站,要求訪客登錄,除非他們從特定的 IP 位址或子網路造訪。
為 Joomla 建立虛擬主機,如下所示:
<VirtualHost *:80>
ServerName joomla.yourdomain.com
ServerAdmin ...
DocumentRoot /var/www/html/joomla
ErrorLog logs/joomla.error_log
<Directory "/var/www/html/joomla">
Options ...
Order allow,deny
Allow from 192.168.1.0/24
Satisfy Any
</Directory>
</VirtualHost>
另外,我希望登入是基於 LDAP 的。
你可以透過使用來做到這一點mod_authz_ldap,像這樣:
LoadModule authz_ldap_module modules/mod_authz_ldap.so
<IfModule mod_authz_ldap.c>
<Location /var/www/html/joomla>
AuthBasicProvider ldap
AuthzLDAPAuthoritative Off
AuthLDAPURL ldap://IP:3268/dc=domain,dc=com?sAMAccountName
AuthLDAPBindDN cn=binduser,dc=domain,dc=com
AuthLDAPBindPassword secret
AuthType Basic
AuthName "Authorization required"
require valid-user
AuthzLDAPLogLevel debug
</Location>
</IfModule>
是否可以選擇使用 LDAP (MS-AD) 進行 HTTPS 驗證?
是的。
答案2
我不確定這是否是您所追求的,但是..
另一種選擇是更改 .htaccess 檔案以允許透過 IP 訪問
<Limit GET>
Order Deny,Allow
Deny from all
Allow from 100.100.100.100
</Limit>
可選:您可以透過用逗號分隔來新增多個位址。
100.100.100.101, 100.100.100.102
答案3
要查看的 Apache 文件是存取控制(“按主機”部分), 身份驗證、授權和存取控制(「滿足」指令),mod_auth_basic, 和mod_authnz_ldap。執行您想要的操作的範例配置是
AuthType Basic
AuthBasicProvider ldap
AuthName "Joomla"
# change the ldap attributes to what matches your environment
AuthLDAPBindDN "uid=example,ou=example,dc=example,dc=com"
AuthLDAPBindPassword example
AuthLDAPURL "ldap://example.com:port/basedn?attribute?scope?filter"
Order allow,deny
# change the ip to match your network that should not have to authenticate
Allow from 10.0.0.0/24
Satisfy any
答案4
您應該將 nginx 設定為代理前端。 Nginx 可以使用以下設定指令來做到這一點:
auth_basic "Restricted";
auth_basic_user_file htpasswd;
satisfy any;
allow 10.0.0.0/24;
allow 10.1.0.0/24;
allow 10.2.1.1;
deny all;
這樣您就可以繞過 中明確列出的 IP 的身份驗證allow
,並為所有其他 IP 提供身份驗證彈出對話框。