nginx ウェブサーバーを閲覧しているときにファイルが表示されません。権限が正しくありませんか?

nginx ウェブサーバーを閲覧しているときにファイルが表示されません。権限が正しくありませんか?

CentOS 7 と nginx 1.12 を使用して、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

関連情報