最近,我已经将我的PHP网站从基本VM迁移到了Google Cloud上具有NGINX入口的Kubernetes。我注意到一个奇怪的问题,偶尔会返回502错误(来自openresty / 1.15.8.2)。对于以前使用过该应用程序并通过清除网站的所有缓存和cookie来解决该问题的人来说,这似乎尤其如此。网站本身完全没有改变。
最奇怪的是,它仅偶尔发生(每天从日志中几次),因此yml文件之间的引用没有问题。
ingress.yml:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: example-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: "true"
cert-manager.io/acme-challenge-type: http01
cert-manager.io/cluster-issuer: letsencrypt
spec:
rules:
- host: "example.app"
http:
paths:
- path: /
backend:
serviceName: example-service
servicePort: 80
tls:
- hosts:
- "example.app"
secretName: example.app-tls
configmap.yml:
kind: ConfigMap
apiVersion: v1
metadata:
name: nginx-config
data:
nginx.conf: |
events {
}
http {
server {
listen 80;
listen [::]:80;
root /app/public;
index index.php index.html index.htm;
server_name example.app;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.css {
add_header Content-Type text/css;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
proxy_connect_timeout 180s;
proxy_send_timeout 180s;
proxy_read_timeout 180s;
send_timeout 180s;
fastcgi_read_timeout 180s;
}
}
如果认为相关,我可以提供更多yml文件。