【发布时间】:2021-08-24 11:15:44
【问题描述】:
我正在测试集群上的共享持久卷。我在 AWS 上创建了一个 EKS 集群,我在其中一个节点上安装了 NFS 服务器,并为其创建了 PV&PVC。我能够使用多个应用程序安装卷。但我无法从 Nginx 服务器访问 html 文件,因为它抛出 403 Forbidden Error.
下面是我的 NFS -Server 的屏幕截图,我的数据在 nginx 上安装了权限
我已将 Nginx 作为 Pod 部署在我的集群上。下面是我的 Nginx 配置文件
nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $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;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
conf.d/default.conf
server {
listen 80;
listen [::]:80;
server_name localhost;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
nginx pod 日志
*22 directory index of "/usr/share/nginx/html/test/" is forbidden, client: 10.14.20.128, server: localhost, request: "GET /test/ HTTP/1.1", host: "*.amazon.com"
getuser?index=0 HTTP/1.1", host: "3.124.54.114:80"
10.14.20.178 - - [07/Jun/2021:08:59:10 +0000] "GET /config/getuser?index=0 HTTP/1.1" 404 153 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0" "-"
2021/06/07 09:03:30 [error] 30#30: *1788 directory index of "/usr/share/nginx/html/test1/" is forbidden, client: 10.14.21.153, server: localhost, request: "GET /test1/ HTTP/1.1", host: ".elb.amazonaws.com"
10.14.21.153 - - [07/Jun/2021:09:03:30 +0000] "GET /test1/ HTTP/1.1" 403 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36" "-"
10.14.21.153 - - [07/Jun/2021:09:12:30 +0000] "GET / HTTP/1.1" 403 153 "-" "Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1" "-"
2021/06/07 09:12:30 [error] 30#30: *1953 directory index of "/usr/share/nginx/html/" is forbidden, client: 10.14.21.153, server: localhost, request: "GET / HTTP/1.1", host: "35.157.4.133"
10.14.21.153 - - [07/Jun/2021:09:12:30 +0000] "GET /HNAP1/ HTTP/1.1" 404 153 "http://35.157.4.133/" "Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1" "-"
2021/06/07 09:12:30 [error] 30#30: *1954 "/usr/share/nginx/html/HNAP1/index.html" is not found (2: No such file or directory), client: 10.14.21.153, server: localhost, request: "GET /HNAP1/ HTTP/1.1", host: "35.157.4.133", referrer: "http://35.157.4.133/"
2021/06/07 09:55:33 [error] 30#30: *2729 directory index of "/usr/share/nginx/html/" is forbidden, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
127.0.0.1 - - [07/Jun/2021:09:55:33 +0000] "GET / HTTP/1.1" 403 153 "-" "curl/7.64.0" "-"
2021/06/07 10:02:47 [error] 30#30: *2828 directory index of "/usr/share/nginx/html/" is forbidden, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"
127.0.0.1 - - [07/Jun/2021:10:02:47 +0000] "GET / HTTP/1.1" 403 153 "-" "curl/7.64.0" "-"
【问题讨论】:
-
更改NFS上的文件权限,让nginx可以访问和服务。
-
您好,感谢您的回复!如果您看到随附的屏幕截图,我对所有文件都有 777 权限
-
很抱歉我错过了它只是阅读了主要问题。为什么不检查 nginx 入口控制器 pod 的日志?
-
还尝试将 nginx 配置中的服务名称更新为
server_name _;,而不是使用Localhost的值。 github.com/harsh4870/Kubernetes-wordpress-php-fpm-nginx/blob/… -
我对这些东西不熟悉,你能把我重定向到一些可以帮助我的博客/文档
标签: nginx kubernetes nfs amazon-ebs