在 Nginx Ingress 后面创建 apache httpd 转发代理

Create apache httpd forward proxy behind Nginx Ingress

我需要在 k8s (GKE) 集群上创建一个正向代理。 为此,我创建了一个简单的 httpd 部署和一个基本的 Nginx Ingress(具有配置良好的服务)。

正向代理配置:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
<VirtualHost *:80>
   HttpProtocolOptions Unsafe
   ErrorLog /var/log/test.log
   LogLevel debug
   CustomLog /var/log/test2.log combined
   ProxyPreserveHost On
   ProxyRequests On
   ProxyVia On
   ProxyStatus On
   ProxyTimeout 60
   AllowCONNECT 1080 443 8443 9443 8000-8900
   <Proxy "*">
      Allow from all
   </Proxy>
</VirtualHost>

Nginx 入口:


apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: stat-proxy
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
    - host: <somehost>
      http:
        paths:
          - path: /
            backend:
              serviceName: stats-service-proxy
              servicePort: 80

当 运行 来自 pod 内部的命令 curl -L -x http://127.0.0.1:80 -I http://www.google.com 时,它按预期工作并且 returns 状态代码 200

当 运行 命令 curl -x http://<ingress-nginx-hostname>:80 -I http://www.google.com 时,我从看起来像 Ingress:

的地方收到错误 404
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

我没有使用 Ingress,而是将服务类型更改为 LoadBalancer