Apache는 권한이 설정된 경우에도 심볼릭 링크를 따르지 않습니다.

Apache는 권한이 설정된 경우에도 심볼릭 링크를 따르지 않습니다.

권한이 괜찮아 보이고 FollowSymLinks가 켜져 있어도 아파치가 웹 루트 디렉토리 외부의 심볼릭 링크를 따르도록 할 수 없습니다. 자세한 내용은 다음과 같습니다.

누구나 읽을 수 있는 두 개의 텍스트 파일이 있습니다: /tmp/hello/var/www/html/hello. 또한 webroot에는 두 파일 모두에 대한 심볼릭 링크가 있습니다. 둘 다 괜찮은 것 같습니다.

$ 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는 웹 루트에 대한 링크를 따라갈 수 있습니다.

$ curl http://localhost/link-local
/VAR/WWW/HTML/HELLO

그러나 Apache는 다음에 대한 심볼릭 링크를 따르지 않습니다 /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>

이것은 CentOS 6에 있습니다. http는 사용자 아파치, 그룹 아파치로 실행됩니다.

왜 이런 일이 발생합니까? 어떻게 해결할 수 있나요?

답변1

예, SELinux가 원인인 것 같습니다.

-Z 스위치는 대부분의 유틸리티에서 작동하여 SELinux 보안 컨텍스트(예: 'ls -Z', 'ps axZ' 등)를 표시합니다.

$ 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

두 대상 파일의 유형이 다르므로( httpd_sys_content_tvs user_tmp_t) 이는 접근성의 차이를 설명합니다.

그만큼centos.org의 SELinux 페이지-Z스위치와 훨씬 더 많은 내용을 설명합니다 .

답변2

.htaccess 파일에 FollowSymlinks를 설정하고 있습니까? 아니면 <Directory>블록에?

Apache 2.2 옵션 문서FollowSymlinks는 이러한 컨텍스트에서만 작동할 것이라고 제안합니다. 관련 구성을 게시할 수 있습니까?

(코멘트 할 포인트가 부족하여 답변으로 게시)

관련 정보