暴露FastCGI服务器
FastCGI 是一个用于交互程序与web server交互的 二进制协议 的交互程序接口. [...] 目的是减少与Web服务器和CGI程序之间的接口相关的开销,使服务器每单位时间处理更多的Web页面请求。 — Wikipedia
ingress-nginx ingress controller可用于直接暴露 FastCGI 服务. 在Ingress中启用FastCGI只需要将backend-protocol注释设置为FCGI,并且通过添加更多注释,您可以自定义ingress-nginx处理与FastCGI server的通信的方式。
公开FastCGI Pod的示例对象
下面的Pod示例对象公开了端口9000,这是常规的FastCGI端口.
apiVersion: v1
kind: Pod
metadata:
name: example-app
labels:
app: example-app
spec:
containers:
- name: example-app
image: example-app:1.0
ports:
- containerPort: 9000
name: fastcgi下面的 Service 对象示例与上面的Pod对象的端口9000相匹配.
下面的Ingress和ConfigMap对象演示了受支持的FastCGI特定注释(NGINX实际上具有50个FastCGI指令,所有这些指令都尚未在入口中公开),并且与服务example-service和名为fastcgi的端口相匹配。从上面。 必须首先创建ConfigMap **,以便Ingress Controller能够在创建Ingress对象时找到它,否则,您将需要重新启动 _Ingress Controller_pods。
FastCGIingress注释
nginx.ingress.kubernetes.io/backend-protocol 注解
nginx.ingress.kubernetes.io/backend-protocol 注解为开启 FastCGI, backend-protocol 需要设置为 FCGI, 将覆盖默认的 HTTP.
nginx.ingress.kubernetes.io/backend-protocol: "FCGI"
为开启全局 Ingress 对象模式 FastCGI FastCGI 模式.
The nginx.ingress.kubernetes.io/fastcgi-index Annotation
nginx.ingress.kubernetes.io/fastcgi-index Annotation指定一个索引文件,fastcgi-index 注释值可以选择设置. 下面设置, 值设置为 index.php. 该注释对应于 the NGINX fastcgi_index directive.
nginx.ingress.kubernetes.io/fastcgi-index: "index.php"
The nginx.ingress.kubernetes.io/fastcgi-params-configmap Annotation
nginx.ingress.kubernetes.io/fastcgi-params-configmap Annotation为指定 NGINX fastcgi_param directives, fastcgi-params-configmap 注解将被使用, 反过来必然导致 ConfigMap 对象包含 NGINX fastcgi_param 指令作为键/值.
nginx.ingress.kubernetes.io/fastcgi-params: "example-configmap"
和 ConfigMap 对象 用于指定 SCRIPT_FILENAME 和 HTTP_PROXY NGINX's fastcgi_param 指令将如下所示:
使用 namespace/ prefix 也被支持, for example:
nginx.ingress.kubernetes.io/fastcgi-params: "example-namespace/example-configmap"
Last updated
Was this helpful?