Hola lista, Tengo un problema con Apache2::AuthenNTML y mod_rewrite. Es posible que esto sea un offtopic, pero como no encuentro mas informacion de este problema puede que sea algo específico de Debian (aunque sinceramente me temo que no).
Este es el entorno que tengo: - Debian Etch - Apache 2 (2.2.3-4) - Perl 5.8.8-7 - libapachache2-mod-perl2 - Controlador de dominio con Windows 2003 Server Tenemos una directiva <Location /> en Apache que requiere autenticación NTLM para todo el contenido que sirve usando Apache2::AuthenNTLM, autenticando en un dominio con un servidor Windows 2003. Todo funciona correctamente cuando el contenido que se pide está en el propio Apache, colgando del DocumentRoot. El problema es que se prentende servir contenidos desde un servidor Tomcat a través del Apache utilizando una regla con mod_rewrite. Cuando se intenta acceder a algo a traves del RewriteRule, el servidor devuelve directamente un error "401 Authorization Required", y no pide ni usuario ni contraseña. Por ejemplo, pidiendo estas URLs desde un navegador (Firefox y IE 6.0), usando la IP del servidor: http://10.9.133.0 (Archivo /var/www/index.html) <--- Funciona bien http://10.9.133.0/example/index.html (Archivo /var/www/example/index.html ) <--- Tambien bien La autenticación funciona perfectamente. Pero cuando le pedimos contenido que viene por el rewrite, no lo hace bien. Esta es la regla del rewrite, que pasa todo lo que pidamos por "test" al Tomcat: RewriteRule ^/test(.*) http://10.9.133.0:9673/$1 [P,L] Si pedimos, por ejemplo, un script de pruebas del servidor llamado "test": http://10.9.133.0/test/test (Corresponde realmente a http://10.9.133.0:9673/test ) <-- 401 Error Los rewrites funcionan correctamente solo si antes hemos hecho una autenticacion correctamente, por ejemplo, si antes le pido la pagina raiz del servidor, me autentico, y despues le pido el "test". El problema es que con este comportamiento no se puede acceder directamente a ningún contenido del rewrite, osea, que no podriamos tener enlaces porque no funcionarían a menos que ya tengamos sesión, ya que te suelta el 401 directamente y no te pide ni usuario ni contraseña. Estos son los logs de Apache para este tipo de peticiones: [20330] AuthenNTLM: Start NTLM Authen handler pid = 20330, connection = 139690552 conn_http_hdr = keep-alive main = cuser = remote_ip = 10.9.236.124 remote_port = 13872 remote_host = <> version = 0.02 smbhandle = [20330] AuthenNTLM: Setup new object [20330] AuthenNTLM: Config Domain = dom_csd1 pdc = sdc1 bdc = [20330] AuthenNTLM: Config Default Domain = Dom_csd1 [20330] AuthenNTLM: Config Fallback Domain = [20330] AuthenNTLM: Config AuthType = basic,ntlm AuthName = Autenticacion bajo NTLM [20330] AuthenNTLM: Config Auth NTLM = 1 Auth Basic = 1 [20330] AuthenNTLM: Config NTLMAuthoritative = on BasicAuthoritative = on [20330] AuthenNTLM: Config Semaphore key = 23754 timeout = 1 [20330] AuthenNTLM: Config SplitDomainPrefix = 1 [20330] AuthenNTLM: Authorization Header <not given> [Tue Jun 12 12:15:09 2007] [error] Bad/Missing NTLM/Basic Authorization Header for /test/test Aqui el navegador ya tiene el error 401. Después de un rato, aparece otro bloque similar en la traza, supongo que cuando da el timeout definitivo: [20332] AuthenNTLM: Start NTLM Authen handler pid = 20332, connection = 138433448 conn_http_hdr = main = cuser = remote_ip = 127.0.0.1 remote_port = 13362 remote_host = <> version = 0.02 smbhandle = [20332] AuthenNTLM: Setup new object [20332] AuthenNTLM: Config Domain = dom_csd1 pdc = sdc1 bdc = [20332] AuthenNTLM: Config Default Domain = Dom_csd1 [20332] AuthenNTLM: Config Fallback Domain = [20332] AuthenNTLM: Config AuthType = basic,ntlm AuthName = Autenticacion bajo NTLM [20332] AuthenNTLM: Config Auth NTLM = 1 Auth Basic = 1 [20332] AuthenNTLM: Config NTLMAuthoritative = on BasicAuthoritative = on [20332] AuthenNTLM: Config Semaphore key = 23754 timeout = 1 [20332] AuthenNTLM: Config SplitDomainPrefix = 1 [20332] AuthenNTLM: Authorization Header <not given> [Tue Jun 12 12:17:54 2007] [error] Bad/Missing NTLM/Basic Authorization Header for / Estos logs son iguales que cuando pides algo y al salir la ventana de la contraseña pulsas el botón de cancelar. Os pongo también el archivo de configuración de Apache que estamos utilizando: <VirtualHost *:80> RequestHeader set REMOTE_USER "%{REMOTE_USER}s" DocumentRoot /var/www/ ServerName 10.9.133.0 KeepAlive On <Location /> PerlAuthenHandler Apache2::AuthenNTLM AuthName "Autenticacion bajo NTLM" AuthType basic,ntlm PerlAddVar ntdomain "Dom_csd1 sdc1" PerlSetVar defaultdomain Dom_csd1 PerlSetVar ntlmdebug 1 PerlSetVar splitdomainprefix 1 PerlSetVar ntlmsemtimeout 1 PerlSetVar ntlmauthoritative on PerlSetVar basicauthoritative on require valid-user </Location> ErrorLog /var/log/apache2/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On <IfModule mod_rewrite.c> RewriteEngine On RewriteLogLevel 3 RewriteLog /var/log/apache2/rewrite.log ### Content running in Tomcat RewriteRule ^/test(.*) http://10.9.133.0:9673/$1 [P,L] </IfModule> </VirtualHost> ¿Alguna idea? ¿Porqué funciona todo bien excepto el rewrite? ¿Porque el navegador no llega a pedir la contraseña? Antes de usar NTLM hemos usado el modulo Apache2::AuthenMSAD con esta misma configuración y funciona correctamente en todos los casos, pero claro, no es lo mismo porque no podemos autenticar automáticamente a los usuarios de Windows con su cuenta de usuario del equipo, nos interesa poder usar NTLM. Un saludo para todos y a ver si alguien me puede aportar algo de luz. Gracias. -- First they ignore you... Then they laugh at you... Then they fight you... Then you win Mohandas Ghandi Use Linux

