nginx 웹서버를 탐색할 때 파일을 볼 수 없습니다. 권한이 잘못되었나요?

nginx 웹서버를 탐색할 때 파일을 볼 수 없습니다. 권한이 잘못되었나요?

저는 nginx 1.12와 함께 centos 7을 사용하여 yum 저장소를 로컬로 호스팅하고 있습니다. 브라우저를 통해 파일을 탐색하려고 하면 폴더가 보이지만 그 안에 파일이 없습니다. 올바른 권한이나 소유권을 설정하지 않았는지 궁금합니다.

이것은 내 설정입니다. 추가 항목, 업데이트 등을 위한 모든 패키지를 경로에 동기화했습니다.

/var/www/html/repos/centos/7/os/x86_64

권한은 다음과 같습니다.

ls -l /var/www
drwxrwx--x. 3 root nginx 19 Aug 30 09:12 html

ls -l /var/www/html
drwxr-xr-x. 4 root nginx 32 Aug 30 09:12 repos

ls -l /var/www/html/repos
drwxr-xr-x. 3 root nginx 15 Aug 30 09:12 centos

ls -l /var/www/html/repos/centos
drwxr-xr-x. 3 root nginx 45 Aug 30 09:12 7

ls -l /var/www/html/repos/centos/7
drwxr-xr-x. 3 root nginx 20 Aug 30 09:12 os
drwxr-xr-x. 3 root nginx 20 Aug 30 09:12 updates
drwxr-xr-x. 3 root nginx 20 Aug 30 09:12 extras

ls -l /var/www/html/repos/centos/7/os
drwxr-xr-x. 8 alexl alexl 237 Aug 30 09:12 x86_64

브라우저를 통해 패키지 폴더에 액세스하려고 하는데 파일이 표시되지 않습니다. 권한은 다음과 같습니다:

ls -l /var/www/html/repos/centos/7/os/x86_64 | grep Packages
drwxr-x-r-x. 2 alexl alexl 565248 Aug 1 18:02 Packages

폴더 내부 파일의 권한:

ls -l /var/www/html/repos/centos/7/os/x86_64/Packages | tail -1
-rw-r--r--. 1 alexl alexl 35380 Jul 4 2014 zziplib-utils-0.13.62-5.el7.x86_64.rpm

이것은 내 nginx.conf 파일입니다.

user              nginx;  
worker_processes  auto;
error_log         /var/log/nginx/error.log;
pid               /run/nginx.pid;

events {
  worker_connections  1024;
}

http {
    log_format   main '$remote_addr - $remote_user [$time_local]  $status '
    '"$request" $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';

    access_log          /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    include /etc/nginx/conf.d/*.conf;

}

사이트 구성은 다음과 같습니다.

server { # simple load balancing
  listen          80;
  server_name     mysecretdomain.com;
  root            /var/www/html/repos;

  location / {
    autoindex on;
  }
}

답변1

일반 파일 시스템 권한 외에도 RHEL 및 CentOS에는 기본적으로 SELinux 필수 액세스 제어가 활성화되어 있습니다. 파일의 레이블이 올바르게 지정되지 않았을 가능성이 높습니다.

웹 콘텐츠의 기본 파일 시스템 위치를 사용하고 있으므로 다음을 사용하여 기본 SELinux 보안 컨텍스트를 복원할 수 있습니다.restorecon

 restorecon -R /var/www/html/repos

SELinux 문제 해결에 대한 모아레 세부 정보: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/selinux_users_and_administrators_guide/chap-security-enhanced_linux-troubleshooting

관련 정보