一般来说,GET 和 POST 都可以工作。
但是,即使 Pod 日志显示响应代码 200,POST 到特定用例也会给出响应代码 502。我不知道如何进一步调试它。
预期行为
Request URL: https://example.foo/api/rpc/request-password-reset
Request Method: POST
Status Code: 200 OK
Pod 日志
26/Oct/2023:07:35:22 +0000 "POST /api/rpc/request-password-reset" 200
预期行为(使用无效凭据登录)
Request URL: https://example.foo/api/login
Request Method: POST
Status Code: 401 Unauthorized
Pod 日志
26/Oct/2023:07:59:41 +0000 "POST /api/login" 401
非预期行为(使用有效凭据登录)
Request URL: https://example.foo/api/login
Request Method: POST
Status Code: 502 Bad Gateway
Pod 日志
26/Oct/2023:07:40:15 +0000 "POST /api/login" 200
在这里您可以看到不匹配的响应代码。
我还禁用了可能发生的 cookie 设置,但仍然会发生代码不匹配的情况。
日志的其余部分不显示任何关键或错误事件。
这是入口
# see https://kubernetes.github.io/ingress-nginx/user-guide/fcgi-services/
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}
data:
SCRIPT_FILENAME: "/home/api/public/index.php"
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Release.Name }}
annotations:
nginx.ingress.kubernetes.io/backend-protocol: "FCGI"
nginx.ingress.kubernetes.io/fastcgi-index: "index.php"
nginx.ingress.kubernetes.io/fastcgi-params-configmap: {{ .Release.Name }}
spec:
ingressClassName: nginx
rules:
- host: {{ .Values.host }}
http:
paths:
- path: /api
pathType: Prefix
backend:
service:
name: {{ .Release.Name }}
port:
name: fastcgi
有什么想法如何进一步调试或修复它吗?
我认为你应该在 nginx yaml 文件中添加如下注释。
nginx.ingress.kubernetes.io/proxy-buffer-size:“128k”
您还应该更改云平台提供的负载均衡器的请求标头大小,如上述大小。