我在 Kubernetes 中的一個 pod 中運行 Nginx 和 wordpress-fpm。影像存盤在 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/uploads 中的媒體(影像)外,一切正常。我在加載此影像時收到 404。
我的 nginx 默認以 root 身份運行。wp-content 檔案夾所有者是 www-data:www-data fpm 日志或 nginx 錯誤日志中沒有任何內容。
無法理解和除錯根本原因。Nginx 是否有可能不遵循符號鏈接?
UPD1。
我正在檢查 nginx 和 nginx 容器,但無法從中訪問符號鏈接。所以我的符號鏈接是在應用程式容器中創建的,nginx 無法看到它。
uj5u.com熱心網友回復:
所以解決方案:efs 需要掛載到同一路徑的兩個容器上,這樣兩個容器都可以訪問它。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/347881.html
標籤:php WordPress的 nginx Kubernetes
上一篇:帶有命名空間的Ingress和Angular-如何在不更改url的情況下通過Ingress重新路由到正確的命名空間
下一篇:java.lang.NoClassDefFoundError:scala/collection/convert/DecorateAsScala但pom.xml中的scala-library在JBoss
