【发布时间】:2021-11-25 19:51:49
【问题描述】:
我在一个 pod 中将 FPM 和 nginx 作为两个容器运行。我的应用程序正在运行,我可以访问它,但浏览器不呈现 CSS 文件。控制台中没有错误。 我的部署文件:
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
labels:
app: test
spec:
replicas: 1
selector:
matchLabels:
app: test
template:
metadata:
labels:
app: test
spec:
volumes:
- name: shared-files
emptyDir: {}
- name: nginx-config-volume
configMap:
name: test
containers:
- image: test-php
name: app
ports:
- containerPort: 9000
protocol: TCP
volumeMounts:
- name: shared-files
mountPath: /var/appfiles
lifecycle:
postStart:
exec:
command: ['sh', '-c', 'cp -r /var/www/* /var/appfiles']
- image: nginx
name: nginx
ports:
- containerPort: 80
protocol: TCP
volumeMounts:
- name: shared-files
mountPath: /var/appfiles
- name: nginx-config-volume
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
Nginx 配置:
events {
}
http {
server {
listen 80;
root /var/appfiles/;
index index.php index.html index.htm;
# Logs
access_log /var/log/nginx/tcc-webapp-access.log;
error_log /var/log/nginx/tcc-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_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;
}
}
}
我可以在浏览器中打开页面,我可以看到所有组件、链接、按钮等,但是页面没有渲染,看起来 css 没有加载。
【问题讨论】:
标签: php nginx kubernetes fpm