No puedo hacer que Apache siga enlaces simbólicos fuera del directorio raíz web, aunque los permisos parecen correctos y FollowSymLinks está activado. Los detalles están a continuación.
Tengo dos archivos de texto legibles en todo el mundo: /tmp/hello
y /var/www/html/hello
. También en webroot tengo enlaces simbólicos a ambos archivos. Ambos parecen estar bien.
$ ll /tmp
drwxrwxrwt. 27 root root 4096 Jul 8 13:55 ./
dr-xr-xr-x. 23 root root 4096 Jul 4 23:24 ../
-rw-r--r--. 1 root root 6 Jul 8 13:55 hello
$ ll /var/www/html
drwxr-xr-x. 3 root root 4096 Jul 8 13:56 ./
drwxr-xr-x. 6 root root 4096 Apr 4 12:57 ../
-rw-r--r--. 1 root root 20 Jul 8 14:03 hello
lrwxrwxrwx. 1 root root 5 Jul 8 14:04 link-local -> /var/www/html/hello
lrwxrwxrwx. 1 root root 10 Jul 8 13:56 link-tmp -> /tmp/hello
$ cat /var/www/html/link-local
/VAR/WWW/HTML/HELLO
$ cat /var/www/html/link-tmp
/TMP/HELLO
Apache puede seguir el enlace a la raíz web:
$ curl http://localhost/link-local
/VAR/WWW/HTML/HELLO
Pero Apache no seguirá el enlace simbólico a /tmp/
:
$ curl http://localhost/link-tmp
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /hellolink on this server.</p>
<hr>
<address>Apache/2.2.15 (CentOS) Server at localhost Port 80</address>
</body></html>
Esto está en CentOS 6; http se ejecuta como usuario apache, grupo apache.
¿Por qué está pasando esto? ¿Cómo puedo arreglarlo?
Respuesta1
Sí, parece que SELinux es el culpable:
El modificador -Z funcionará con la mayoría de las utilidades para mostrar contextos de seguridad de SELinux (por ejemplo, 'ls -Z', 'ps axZ', etc.).
$ ll -Z /var/www/html/hello
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 /var/www/html/hello
$ ll -Z /tmp/hello
-rw-r--r--. root root unconfined_u:object_r:user_tmp_t:s0 /tmp/hello
Los dos archivos de destino tienen diferentes tipos ( httpd_sys_content_t
vs user_tmp_t
), lo que explica la diferencia en accesibilidad.
ElPágina de SELinux en centos.orgexplica el -Z
cambio y mucho, mucho más.
Respuesta2
¿Está configurando FollowSymlinks en un archivo .htaccess? o en un <Directory>
bloque?
Documentación de opciones de Apache 2.2sugiere que FollowSymlinks solo funcionará en estos contextos. ¿Podrías publicar la configuración relevante?
(publicando como respuesta debido a que no hay suficientes puntos para comentar)