Nginx - wordpress fpm -得到404的图像存储在wp-content/上传(符号链接到EFS).&l



我在Kubernetes中运行Nginx和wordpress-fpm在一个pod内。图像存储在EFS和EFS文件夹链接到wp-content/uploads文件夹作为符号链接。EFS文件夹是可用的,我可以从容器访问它。

这是我的部署文件:

apiVersion: apps/v1
kind: Deployment
metadata:
name: -deployment
labels:
app: MASSEDIT
spec:
replicas: 1
selector:
matchLabels:
app: MASSEDIT
template:
metadata:
labels:
app: MASSEDIT
spec:
volumes:
- name: efs-pvc
persistentVolumeClaim:
claimName: -efs-storage-claim
- name: shared-files
emptyDir: {}
- name: nginx-config
configMap:
name: -nginx-configmap
containers:
- image: DONTTOUCH-replace-me-kustomization
name: app
ports:
- containerPort: 9000
protocol: TCP
volumeMounts:
- mountPath: /var/www/html
name: shared-files
- mountPath: /shared
name: efs-pvc
- image: nginx
name: nginx
ports:
- containerPort: 80
protocol: TCP
volumeMounts:
- mountPath: /var/www/html
name: shared-files
- mountPath: /etc/nginx/conf.d/default.conf
name: nginx-config
subPath: nginx.conf

这是我的Nginx配置映射:

kind: ConfigMap
apiVersion: v1
metadata:
name: -nginx-configmap
data:
nginx.conf: |
server {
listen       80;
server_name some server;
root   /var/www/html/;
index index.php index.html index.htm;

# Logs
access_log /var/log/nginx/webapp-access.log;
error_log /var/log/nginx/webapp-error.log;
location / {
# try_files $uri $uri/ =404;
# try_files $uri $uri/ /index.php?q=$uri&$args;
try_files $uri $uri/ /index.php?$query_string;
}

location ~ .php$ {
fastcgi_param HTTPS 1;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 300s;
fastcgi_send_timeout 60;
fastcgi_read_timeout 60;
}

}

我能够加载所有的页面和一切工作正常,除了媒体(图像),存储在wp-content/上传。我在加载这些图像时得到404。

我的nginx默认以root运行。Wp-content文件夹的所有者是www-data:www-data在fpm日志或nginx错误日志中没有任何内容。

不能理解和调试根本原因。是否有可能Nginx不遵循符号链接?

UPD1 .

我正在检查nginx和nginx容器,我无法从它访问符号链接。所以我的符号链接是在应用容器中创建的,nginx无法看到它。

所以解决方案:Efs需要以相同的路径挂载到两个容器,这样两个容器都可以访问它。

最新更新